[Pmwiki-users] Skins - a somewhat radical proposal

Patrick R. Michaud pmichaud
Fri Nov 12 15:00:20 CST 2004


[I know that the listserv isn't currently sending out emails so this
might not get to anyone... but I'm still going to take the time to
write it down now and will re-send if necessary.  --Pm]

Okay, having gone out for a nice walk and thought about this some more,
here are some conclusions I've drawn, and some (perhaps radical) ideas
for going further.

First, I think I've finally convinced myself that the setting of some 
parameters such as $LinkPageExistsFmt, $LinkPageCreateFmt, $UrlLinkTextFmt, 
etc., is really to be associated with a -skin- and not with the -action- 
being performed.  Thus those parameters need to be specified using 
something that exists in a skin's directory, and the logical way to do 
such settings is with a .php scripts.  So, skins now get their own
.php scripts.  (Yes, I know that Balu and others have been claiming this
all along, I'm just finally getting my justifications for it in order.)

Second, we don't want force (novice) skin designers to have to write 
.php scripts when they aren't needed, so any .php scripts need to be an
optional component of the skin.

Third, basic skin selection should be as simple as saying $Skin='xyzskin'
in a configuration file, which tells PmWiki to use the skin stored at 
pub/skins/xyzskin, including the loading of the skin's optional .php script.
More advanced features should be possible (e.g., being able to use an array
to select the first available of '$FullName', '$Group', 'xyzskin', and 
'pmwiki' skins), but the basic setting is what the majority of people
will use and be exposed to.

And finally, I now agree with John's idea to allow actions to override the
default skin choice, something like $ActionSkin['print']='xyzprint'.

Okay, now that I've reached those conclusions, all that is left is to
figure out how PmWiki gets from a skin name ('xyzskin') to the individual
template, php, and css files associated with that skin.

One option would be to require that the names of the files match the
name of the skin, as in 'xyzskin.php', 'xyzskin.tmpl', and 'xyzskin.css'.
But I'm going to reject that option outright, because it means that
copying or renaming a skin into a new directory requires making all of
the filenames match.  

The next logical option is to require the skin and template files to always
have the same name, i.e., "skin.php" and "skin.tmpl", or "screen.php" and
"screen.tmpl", etc.  But for some reason I'm inclined to find that a 
little too restrictive as well.

So--here's the somewhat radical part--what if we just go to the other 
extreme, and let the php and template files be named *anything* as long 
as they end in .php or .tmpl.  Thus, with $Skin='xyzskin', PmWiki would 
just use whatever .php and/or .tmpl files it happens to find in 
pub/skins/xyzskin.  

Of course, the question then becomes, what if there's more than one?
For .php files, it could just load all that it finds, but this is
probably a bit dangerous.  Perhaps the better approach is to keep a
restriction that a skin's .php file must be named something like 
"skin.php" or "settings.php" in order to be automatically used.

For selecting from several template files in a skin's directory, I'd
say to first use any template file chosen within skin.php, else 
use the template file with the same name as $Skin if it exists, else 
just use the first .tmpl file we happen to find in the skin's directory, 
whatever it happens to be named.  

Alternately, if we get to the end and find more than one .tmpl file
to choose from, we could issue an error message telling the administrator
to rename one or eliminate the extraneous ones.

This seems to avoid lots of problems for new administrators and
causes things to "just work" in the vast majority of cases.  Copying
and renaming files or directories is no longer an issue, because the
.php file is always named 'skin.php' and the template file
can be any name we want.  The names of .css files don't really
matter here, because they're actually controlled by 
selection algorithm, since any .css files are actually specified in 
the template.  What we do have to provide is a way for the template to 
reference the url of the skin directory -- something like 
$SkinDirUrl/xyzskin.css where $SkinDirUrl is replaced by 
$PubDirUrl/skins/$Skin or $FarmPubDirUrl/skins/$Skin as appropriate.

The only really bizarre part about this proposal is the notion of
"use whatever template you happen to find first" when multiple
templates exist -- this might lead too many people to be confused
by "I'm changing my template but the changes aren't appearing"
because PmWiki keeps selecting a different template.  But maybe
this confusion could be sufficiently reduced by providing appropriate
warnings, errors, or documentation for when it occurs.

Comments?

Pm



More information about the pmwiki-users mailing list