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

Patrick R. Michaud pmichaud
Sat Apr 3 14:28:29 CST 2004


On Sat, Apr 03, 2004 at 11:55:08AM -0800, Wayne Lee wrote:
> 
> 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?

It somewhat goes against the spirit of templates.
However, you can do it indirectly, by doing

   <!--file:special.php-->

which includes a php file at that point.  If there's *great*
demand for it, I could probably come up with a way to enable
<?php ... ?> processing within 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 can often do this quite easily without the "if" statement
by using CSS properties.  For example, the link can be placed in the
template as

   <div class='$Group'><a href='$ScriptUrl/$Group'>link info</a></div>

and then the following config.php statement will add a CSS property turn 
off the link whenever the page name matches the group name:

   $HTMLHeaderFmt[] = "<style type='text/css'>
     .\$Title_ { display:none; }
     </style>";

> (BTW, I'm new to PmWiki and Wikis
> in general and am ridiculously impressed
> by PmWiki's ease of use.  Great job
> all!)

Thanks!

Pm



More information about the pmwiki-users mailing list