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

Patrick R. Michaud pmichaud at pobox.com
Wed Jul 19 14:57:42 CDT 2006


On Fri, Jul 14, 2006 at 01:02:02PM -0700, Jeff Ullmann wrote:
>  
> What I'm trying to do is, when a user creates a new group, in addition
> to the HomePage, have a GroupHeader, GroupFooter, and a third page
> created automatically. All the pages would be created from templates
> (different templates for each page of course :).
> 
> Currently I'm using newgroupbox.php as my starting point, because that,
> and a judicious use of templates and embedded text instructions will do
> most of what I need. I'm just looking for a recipe that creates a page
> with no user intervention other than clicking a link or button.

Note that you probably want to limit it to "clicking a button", since
web spiders will happily click on every link you present to them.  :-)

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.

Pm




More information about the pmwiki-users mailing list