[Pmwiki-users] Embedded php in template (.tmpl) files

H. Fox haganfox
Sat Apr 3 14:58:59 CST 2004


Wayne Lee wrote:
> Hi,
> 
> I'd like to modify the html template to
> include embedded php code to be
> executed by PmWiki before it serves
> up the Wiki page.
> 
> Does anyone know how I can easily
> do this?  Or does this go against the
> spirit of templates?
> 
> Specifically, I want to add a navigation
> link to the main WikiGroup page if
> the current Wiki page title is not the
> same as the WikiGroup name, i.e:
> 
> <?php if ($Group != $Title) echo "[link info goes here]"; ?>

You don't need to embed php in the template.  You put the php code in 
config.php instead.  I just did what you are looking for (I think) last 
night. It needs some refinement, but it's a start...

In my config.php I have this:

$pagname_split = explode('/', $pagename);
if ($pagename==''
  || $pagename=='Main/HomePage'
  || $pagname_split['0'] == $pagname_split['1']) {
  $GroupHdrFmt = "<span id='wikigroupforheader'
  title='$[\$Groupspaced Home]'>\$Groupspaced</a></span>";
} else {
  $GroupHdrFmt = "<span id='wikigroupforheader'>
  <a href='\$ScriptUrl/\$Group'
  title='$[\$Groupspaced Home]'>\$Groupspaced</a></span>";
}

In my template I have this:

   <div id='headcmdsupper'>
     You are in the $GroupHdrFmt section of the site.
   </div>

And the CSS:

#wikigroupforheader { font-weight:bold; }

See the page here (site is under development):

http://qdig.sourceforge.net/qdig/index.php/Qdig/Installation

<commentary>
IMHO a big drawback to wikis is the fact that so many pages have links 
to themselves.  This page explains why it's undesirable:

Lost in Hyperspace: "Avoid self-referring links"
http://www-personal.si.umich.edu/~ulius/navigation/design_go_5.htm

Also see Good Deed #1 here:

useit.com: "Ten Good Deeds in Web Design"
http://www.useit.com/alertbox/991003.html
</commentary>

Hagan




More information about the pmwiki-users mailing list