[Pmwiki-users] Re: Discussion: Turning template parts ON | OFF

Patrick R. Michaud pmichaud
Tue Apr 27 11:14:27 CDT 2004


On Tue, Apr 27, 2004 at 09:21:27AM -0700, Steven Leite wrote:
> 
>    I  remember  there  was  a bit of discussion a while back about how to
>    turn  sidebars  off.   And  then  some  more  discussion  on  adding a
>    LeftSideBar  and RightSideBar.  Can anyone re-cap?  I'd like to try it
>    out  and  see  if  I  can  use  it on my site.  I'm not sure if that's
>    documented or not.
> 
>    Then  ..  why stop there? Wouldn't it be nice to let admin's to define
>    their own page sections/parts?

Sure, just keep in mind that page sections don't nest.  Thus one cannot
do something like:

     <!--PageHeaderFmt-->
        somestuff
        <!--PageLogoFmt-->
          my logo information
        <!--/PageLogoFmt-->
        some other stuff
     <!--/PageHeaderFmt-->

and expect the [[noheader]] directive to work properly.

That said, if someone wants to add a [[nosidebar]] directive to
disable sidebars, then add

   $BrowseDirectives['[[nosidebar]]'] = 
     '$GLOBALS["PageLeftFmt"]=""; $GLOBALS["PageRightFmt"]="";';

to a config.php.  Note that in PmWiki's default template the PageLeftFmt
and PageRightFmt components are "paired" -- setting only one of these to
null will result in invalid HTML.  (I may fix this in the template in
the near future.)

Howver, rather than mucking with all of this, an even better way to
turn off individual components of a template is to make use of the
"display:none" CSS property.  So, if someone wants a directive to turn
off the display logo, it can be done with something like

   $BrowseDirectives['[[nologo]]'] =
     '$GLOBALS["HTMLHeaderFmt"][] = "<style type=\'text/css\'>
       div#wikilogo { display:none; }
       </style>";';

Using this approach, nearly any HTML element can be turned off in the 
template without having to have a lot of <!--...--> sections.

On a somewhat related topic, would it be worthwhile to admins/Cookbook
authors for me to introduce an $HTMLStylesFmt array that could be 
used to store CSS properties and would automatically generate the 
"<style ...> ... </style>" tags in the output?  I.e., if this were
available, the above could be simplified to:

   $BrowseDirectives['[[nologo]]'] =
     '$GLOBALS["HTMLStylesFmt"][] = "div#wikilogo { display:none; }";';

Pm



More information about the pmwiki-users mailing list