[pmwiki-users] Looking for a recipe I can steal -- Create a page with no user interaction.

Tegan Dowling tmdowling at gmail.com
Tue Aug 1 08:08:17 CDT 2006


Argh!  Sorry for the top-post, just minutes ago.  Here I repeat my
post, properly below.

On 8/1/06, Hans Bracker <hans.bracker at googlemail.com> wrote:
> On 19/07/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> > Here's a brief recipe that will create HomePage, GroupHeader, and
> > GroupFooter automatically if they don't exist when a page is created
> > in a group:
> >
> >     function AutoGroupPages($pagename, &$page, &$new) {
> >       global $IsPagePosted, $GroupPagesFmt;
> >       if (!$IsPagePosted) return;
> >       SDV($AutoGroupPagesFmt, array(
> >         '{$Group}.HomePage' => 'Templates.HomePage',
> >         '{$Group}.GroupHeader' => 'Templates.GroupHeader',
> >         '{$Group}.GroupFooter' => 'Templates.GroupFooter'));
> >
> >       foreach($AutoGroupPagesFmt as $n => $t) {
> >         $n = FmtPageName($n, $pagename);
> >         if (!PageExists($n)) {
> >           $t = FmtPageName($t, $pagename);
> >           WritePage($n, ReadPage($t));
> >         }
> >       }
> >     }
> >
> >     $EditFunctions[] = 'AutoGroupPages';
> >
> > As written above, the pages are created based on their
> > equivalents in the Templates group.
>
> I added this function as a (optional) feature to the newgroupbox.php
> script, so a number of pages in a new group can be created
> automatically, all what is necessarty for an author is to type in the
> group name in the newgroupbox.
> http://www.pmwiki.org/wiki/Cookbook/NewGroupBox
Hans:  This is fabulous - it's going to allow me to set up wikis that
are much, much 'friendlier' to new users.  Could I ask you to please
add an example to the documentation?

I gather (but often "gather" incorrectly) that I put these into config.php:
      $EnableAutoGroupPages = 1;
      SDV($AutoGroupPagesFmt, array(
      '{$Group}.HomePage' => 'Templates.MyPage1',
      '{$Group}.HomePage' => 'Templates.MyPage2',
      '{$Group}.HomePage' => 'Templates.HomePage',
      '{$Group}.GroupHeader' => 'Templates.GroupHeader',
      '{$Group}.GroupFooter' => 'Templates.GroupFooter'));
      include_once("$FarmD/cookbook/newgroupbox.php");

And then on a group-launching page, I'd put the form:
(:newgroupbox base=HomePage template=Templates.HomePage save=true:)

Then entering FirstLast into the form and clicking the button will
create FirstLast/HomePage, FirstLast/MyPage1, etc (all the pages in my
customized array), pre-populating the new pages with content from the
corresponding pages in the Templates group.  Is that correct?

With these options in my config, do I not even need to specify base=
and template=?

Am I right in thinking that if I enable the AutoGroupPages option in
my config, then I can't use the newgroupbox in the original way - for
instance, I can't, in some other place in the same wiki, put a box
(:newgroupbox base=Index template=Site.IndexTemplate:)
?

Thanks again - this is amazing!

Tegan




More information about the pmwiki-users mailing list