[pmwiki-users] edit template for specific pages

Patrick R. Michaud pmichaud at pobox.com
Fri Mar 17 12:58:41 CST 2006


On Fri, Mar 17, 2006 at 12:53:48PM -0600, Patrick R. Michaud wrote:
> On Fri, Mar 17, 2006 at 07:38:28PM +0100, noskule wrote:
> > hi list
> > How do I setup a rule that a pagetemplate  will be used if the pagename 
> > is "GroupConfiguration" ? I did try the following, but nothing happens:
> > 
> > $GroupConfiguration = '/*\\*.GroupConfiguration/';
> > 	if ($action == 'edit' && preg_match($GroupConfiguration, $pagename))
> > 	$EditTemplatesFmt = 'Site.GroupConfigurationTemplate';
> > 
> > does anyone has a suggestion?
> 
> $pagename = ResolvePageName($pagename);
> $name = PageVar($pagename, '$Name');
> if ($name == 'GroupConfiguration') 
>   $EditTemplatesFmt = 'Site.GroupConfigurationTemplate';

But even better is:

    $EditTemplatesFmt = 'Site.{$Name}Template';

Yes, just one line!  

This will look in the Site group for a template page matching 
the name of the current page.  Thus Site.GroupConfigurationTemplate 
would be used for any page named "GroupConfiguration", 
Site.HomePageTemplate would be used for any page named "HomePage", etc.
Of course, if there's no matching Site.*Template page, then
no template is used.

Pm





More information about the pmwiki-users mailing list