[pmwiki-users] Determine from which WikiLibDir a page was read?

Patrick R. Michaud pmichaud at pobox.com
Sat May 26 14:08:39 CDT 2007


On Sat, May 26, 2007 at 12:40:23AM +0200, Tobias Thelen wrote:
> Is it possible to display/determine from which PageStore resp. 
> WikiLibDir a page was read? I found no straight-forward way to do so. 
> (maybe I didn't notice..)
> 
> A relatively simple solution to make us happy would be e.g. setting 
> something like $page['wikilibdir'] in ReadPage() (pmwiki.php) and 
> defining a corresponding PageVar.

I've just released pmwiki-2.2.0-beta52, which allows each individual
PageStore to define attributes to be included in each page coming
from that PageStore.  The array of attributes is given as the third
parameter to the PageStore() constructor, or by setting the 'attr'
member of a PageStore object directly.  

For example:

  $WikiDir = new PageStore('wiki.d/{$FullName}', 
                           0, 
                           array('=pagestore' => 'LOCAL'));

means that every page that is read from $WikiDir (wiki.d/)
will have a =pagestore attribute of 'LOCAL'.  Similarly:

  $WikiLibDirs = array(
    &$WikiDir,
    new PageStore('$FarmD/wikilib.d/{$FullName}', 0,
                  array('=pagestore' => 'WIKILIB'))
    );

will cause every page that is read from the farm's wikilib.d/
directory to have a =pagestore attribute of 'WIKILIB'.

The values can also be added after the fact by setting
the ->attr member directly:

    $WikiDir->attr['=pagestore'] = 'LOCAL';
    $WikiLibDirs[1]->attr['=pagestore'] = 'WIKILIB';

Although any attribute name/value pair can be set on a per-PageStore
basis in this way, I highly recommend using only attributes names
that begin with '='.  Using a leading '=' will prevent these
attributes from being saved to pagefiles.  Also, if a pagefile
contains an attribute with the same name as one of the defaults
given in the PageStore's attr array, then the pagefile's value
is used.

Hope this helps.  If there are any questions, just ask.  :-)

Pm



More information about the pmwiki-users mailing list