[Pmwiki-users] SHTML-like templates for PmWiki

niall b durham nbd3355 at sci.tamucc.edu
Sun Dec 15 17:29:34 CST 2002

On Sat, Dec 14, 2002 at 09:56:34AM -0600, Patrick R. Michaud wrote:
> I'm not exactly sure I understand all of the details of Niall's modification--
> it sounds to me like he's making it possible to set the PmWiki headers/footers
> without having to embed HTML within PHP variables (e.g., $PageHeaderFmt,
> $PageFooterFmt, etc.).  I had been thinking of doing something along this
> lines but in a slightly different form...

You appear to understand my intent.

I had two goals with the modification.  I wanted to give someone w/o
knowledge of PHP and PHP syntax (but with S/HTML familiarity) the
capability to easily modify the look and HTML generation of PmWiki 
pages.  In addition, I didn't want to modify any PmWiki code to do
this (if possible)--and potentially cut myself off from future
upgrades.  As it turned out, due to the (good) design of PmWiki, I 
didn't have to modify it. 

Off the cuff, the only benefit (neglecting the many disadvantages) of
my approach over the proposed is that template.php searches through
the header/footer after processing all the valid directives and aborts 
with a list of the invalid directives (if any).  However, given that PHP
usually displays helpful error messages, I don't believe this is a
significant benefit.

> On the <--#pmwiki var="ScriptDir"--> syntax, I'm not so sure this is the
> right way to go about it.  Rather than introduce the SHTML syntax
> into PmWiki and force PmWiki to parse/process it, let's find a way to 
> just drop directly into PHP again somehow.  I.e., I think that writing
> 	<?php echo $ScriptDir; ?>
> is as easy to learn as writing
>         <!--#pmwiki var="ScriptDir"-->
> even for someone who is unfamiliar with PHP.  For those with more
> familiarity with PHP this would be a huge win, because they can embed
> expressions and entire PHP statements.

During implementation, I was unsure about my clunky SHTML-like syntax.  
I like this idea better.  For these expressions, the PHP syntax has 
the same complexity.  However, its less restrictive, more flexible, and 
easier to implement.

Damn, you're good. :)

> As long as we're doing it this way, why not just use the PHP syntax
> for Niall's proposal from the outset?  Let the administrator create
> an HTML file containing embedded PHP instead of SHTML.  This results
> in the following replacements for Niall's directives:
>     <!--#include file="foo.inc"-->
> 	becomes
>     <?php include("foo.inc"); ?>
>     <!--#pmwiki body-->
> 	becomes
>     <?php PrintWiki(); ?>
>     <!--#pmwiki var="ScriptDir"-->
> 	becomes
>     <?php echo $ScriptDir ?>

I like this approach.  The only snag I'm wondering about is the current
directory when the include() is processed.  In the template.php
script, it uses the path of the template file as the filename prefix for 
the include statement.  For example, say I have the following directory


If we want to include the foo.inc file from within the Main.tmpl file,
using the template.php syntax, I have the following directive:

    <!--#include file='foo.inc'-->

In comparison, say Main.tmpl was included via the PHP mechanism.  
Assuming that the CWD is pmwiki/, then as I understand things, I would 
have to use the following directive:

    <?php include("template/foo.inc"); ?>

I find this slightly confusing/annoying.  However, we could modify 
the include_path, or set the CWD before processing a template, so I
suppose I'm just niggling.  (Come to think of it, that pretty much
characterizes most of my development efforts :)

> Niall--can I get a copy of the local modifications you created to take a 
> look and possibly steal some ideas?

No problemo.  I've included the .tgz file (creates a directory named
'wiki-test' with the template.php script and a silly test example) in 
this e-mail.

> Pm


nbd3355 at sci.tamucc.edu

More information about the pmwiki-users mailing list