[Pmwiki-users] [PATCH] Allow setting of BasicLayoutVars in local/group/page config

Patrick R. Michaud pmichaud
Mon Jun 21 07:31:20 CDT 2004


On Mon, Jun 21, 2004 at 09:02:32AM -0400, Ari Pollak wrote:
> Currently, putting something like $PageHeaderFmt='blah'; in 
> local/Group.php to override just the PageHeaderFmt section of the site 
> template does not work, because scripts/tlayout.php overrides all of the 
> section globals regardless of whether they are previously set or not. 

tlayout.php doesn't check if variables are previously set because this would
make it difficult to use the template to set variables that *are* already
set, such as $PageEditFmt.  Yes, there are sites that use the templates in
this way.

At present, an easy way to customize the BasicLayoutVars in a config file 
is to simply do

   include_once("$FarmD/scripts/tlayout.php");

prior to doing any local settings.

I don't have any problem implementing a patch like the one given, but
this would mean moving the default settings for $PageEditFmt and others
into the functions that use them instead of prior to any customizations.
(Also, we should use PHP's isset() function instead of defined() for this.)

Pm



> The attached patch makes tlayout.php only set the global BasicLayoutVars 
> (like $PageHeaderFmt) if they're not defined yet, thus making the local 
> config take precedence over the defined template.
> I haven't found any problems with this nor can I forsee any, I'd only 
> imagine that this would make local customizations much easier. (If tihs 
> patch goes in, I'll update the appropriate wiki pages on the site to 
> reflect that this is now possible, which it should have been before)

> --- scripts/tlayout.php.orig	2004-06-21 03:14:46.000000000 -0400
> +++ scripts/tlayout.php	2004-06-21 03:16:39.000000000 -0400
> @@ -68,7 +68,10 @@
>        $GLOBALS[$ps][] = (count($v)>1) ? $v : $v[0];
>        continue;
>      } 
> -    $GLOBALS[$k] = (count($v)>1) ? $v : $v[0];
> +	// If a section global has already been defined, use that instead of
> +	// template section
> +    if(!defined($GLOBALS[$k]))
> +		$GLOBALS[$k] = (count($v)>1) ? $v : $v[0];
>      if (in_array($k,$BasicLayoutVars)) {
>        $GLOBALS[$ps][] = "<!--$k-->";
>        if ($k=='PageText') { $ps = 'PageEndFmt'; }

> -- 
> Pmwiki-users mailing list
> Pmwiki-users at pmichaud.com
> http://pmichaud.com/mailman/listinfo/pmwiki-users_pmichaud.com




More information about the pmwiki-users mailing list