[pmwiki-users] Shared Pages

Eemeli Aro eemeli at gmail.com
Sat Sep 12 11:21:50 CDT 2009

2009/9/12 Simon <nzskiwi at gmail.com>:
> In config.php I have
>   $WikiDir = new PageStore('wiki.d/$Group/$FullName');

You shouldn't need to re-define PageStore with that same definition.
Instead, you should use array_splice to add your shared PageStore as
the second entry in $WikiLibDirs.

> What I want to achieve is having some shared groups of pages that can be
> updated and added to (ie new pages) from both websites.
> Where a group is not in the shared directory I want it to update the local
> website folder (this happens now).
> My understanding of the above (its not on the page, but I will add it if I
> am right),
> is that existing pages are updated in their existing locations, but new
> pages are added in to local folder.
> This is because of the ordering of the WikiLibDirs array.
> Now there is a separate thread about page stores etc,
> perhaps that discussion could be expanded encompass the use of multiple
> stores,
> and shared uploads directories as well,
> with the capability to work on a group basis.
> If anyone can suggest how I can have all new pages in a shared group only be
> added the the shared directory I would appreciate it

Yes. The place where this is determined is the WritePage function in
pmwiki.php. If you want to change how it works, you'll need to edit
pmwiki.php directly, as this isn't parameterised. Try something like
the following (haven't tested this, though...):

in WritePage, at about line 1013, replace the following:

  if ($i >= count($WikiLibDirs)) $wd = &$WikiDir;


  if ($i >= count($WikiLibDirs)) {
    $grouphome = MakePageName($pagename,
      preg_replace('#[^/.]+$#', '', $pagename));
    for($i=0; $i<count($WikiLibDirs); ++$i) {
      $wd = &$WikiLibDirs[$i];
      if ($wd->iswrite && $wd->exists($grouphome)) break;
    if ($i >= count($WikiLibDirs)) $wd = &$WikiDir;

> A corollorry questions
> I can test for a pagename in config.php by using   $pagename =
> ResolvePageName($pagename);
> How can I test for a groupname in config.php?

ResolvePageName should only be called to resolve the $pagename of the
actual page being viewed. It has side effects in some cases, eg.
forcing a redirect to a corrected page name or returning a 404. To
test or resolve an arbitrary string to a page name, the function you
should use is MakePageName.

And could you clarfiy what you mean by testing for groupname?


More information about the pmwiki-users mailing list