[pmwiki-users] Skins and wikilib.d

Patrick R. Michaud pmichaud at pobox.com
Tue May 22 16:30:16 CDT 2007


On Tue, May 22, 2007 at 01:13:50PM -0400, DaveG wrote:
> 
> According to this http://pmwiki.com/wiki/Cookbook/SkinGuidelines#pages, 
> skins can have their own wikilib.d directories. This seems to be a great 
> place to store wiki specific pages, etc. 

Out of curiosity, what do you mean by "wiki specific pages"?

> Question is how do I *add* my skin wikilib.d to the default list? 
> I'm not sure I understand the sample code on the page. 
> 
> ## Add a custom page storage location for the
> ## custom Edit Form and a Preferences page.
> global $WikiLibDirs;
> $PageStorePath = dirname(__FILE__)."/wikilib.d/{\$FullName}";
> $where = count($WikiLibDirs);
> if ($where>1) $where--;
> array_splice($WikiLibDirs, $where, 0,
>   array(new PageStore($PageStorePath)));

I'll try and explain it.  We want to create a new PageStore
object for the skin's wikilib.d/, and place it _just before_ the
last PageStore in the $WikiLibDirs.

Normally the above code goes into the skin's skin.php file,
so __FILE__ returns the location of the skin.php file.  
It follows then that dirname(__FILE__) is the directory
of the skin itself, and to that we add "/wikilib.d/{\$FullName}"
to get the specification for page files held in the skin's
wikilib.d/ subdirectory.

Once we know where the page files are at, we now want
to splice it as the second-to-last entry in $WikiLibDirs.
The last entry of $WikiLibDirs is nearly always the
farm's wikilib.d/ directory; we want the skin's wikilib.d/
to appear just before that so that page files provided by the
skin get precedence.

The "if ($where>1) $where--;" statement is guarding against
the possibility that there's only one directory in $WikiLibDirs,
which would likely be wiki.d/ .  We don't want the skin's
wikilib.d/ to get priority over locally edited pages.

Hope this helps.

Pm



More information about the pmwiki-users mailing list