[Pmwiki-users] Re: Skins - a somewhat radical proposal

Patrick R. Michaud pmichaud
Sun Nov 14 16:41:21 CST 2004


On Mon, Nov 15, 2004 at 11:04:53AM +1300, John Rankin wrote:
> On Saturday, 13 November 2004 10:59 AM, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> 
> >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.  
> 
> FAD an administrator can still set these globally in config.php
> but a particular skin may override such settings. And the print skin
> does this already.

Yes.

> And they move out of pmwiki.php and into pub/skins/pmwiki/skin.php

No.  We still have to have defaults for these settings so that not
every skin directory requires a .php file.  They *might* move to be
after the local configuration, with appropriate SDVs.

> >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.
> 
> IMO one tidy way to do this is to have an array of $Skins. PmWiki does
> something like:
>     foreach ($Skins as $s) {
>         $Skin = $s;
> [...]

I think people might be confused by the separate $Skin and $Skins variables,
because they differ by just one character.  I think I would prefer to just
have $Skin, which can be a single value or an array.  If it is an array,
then PmWiki collapses it down to a single value when it performs the loop.

Also, I hadn't really thought about the case of loading multiple 
skins on top of each other--(i.e., executing *multiple* skin.php files),
that seems like it has lots of potential for confusion.  For clarity
it might be better to just reverse the sense of the array and simply
load the first skin found.  I'll have to think on this a bit.

> >And finally, I now agree with John's idea to allow actions to override the
> >default skin choice, something like
> >$ActionSkin['print']='xyzprint'.
> 
> FAD scripts/print.php moves into pub/skins/print/

Yes.

> >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.
> 
> IMO it should look first for skin.php and then $Skin.php but
> load only the first it finds. 

Any particular reason for supporting $Skin.php as opposed to just 
"skin.php"?

> >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.
> 
> IMO the order should be a template file set in skin.php (or $Skin.php
> if there is no skin.php), skin.tmpl, then $Skin.tmpl, then a file with
> a .tmpl extension -- so the order and naming is the same as for the 
> .php files (if there is no setting in the .php file).

I'm not too fond of that skin.tmpl file -- if someone copies a skin
directory, then copies skin.tmpl to xyzskin.tmpl to make changes, 
skin.tmpl still gets precedence.

> >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.
> 
> IMO this is unnecessarily restrictive. [...]
> I think there should only be an error
> in the following case:
> - a .php file doesn't set a template
> - neither skin.tmpl not $Skin.tmpl exists
> - there are more than 2 .tmpl files in the $Skin/ directory

Sorry about that, I should've omitted the word "Alternately" in my original.
What is listed here is exactly what I intended (with the exception
of the skin.tmpl file).

> A case could be made that the .php files work the same way --
> look for skin.php then $Skin.php then anyname.php

I thought about this, but I'm a bit wary about having PmWiki load just
any .php file it finds (even in this restricted context).  I prefer it
to be fairly precise.

> It would be easier to explain if the rule was the same for
> .php and .tmpl files, with the addition that a .php file can
> override the .tmpl rule. For me, skin then $Skin is enough,
> as the .php can invoke any.tmpl if needed.

Well, that's why I was avoiding the multiple .php file option and staying
away from $Skin.php.  It's easy to explain that a skin's .php file must 
be named "skin.php", and a template is the first of
    - set by skin.php
    - $Skin.tmpl
    - any .tmpl file in the skin directory, if there's only one
    - an error if none of the above are satisfied

This "just works" for all of the skin copying/modification scenarios that
I can come up with (it even works for "skin.tmpl" even though it's not
explicitly listed in the rules).

Pm



More information about the pmwiki-users mailing list