[Pmwiki-users] Skinning once more

Patrick R. Michaud pmichaud
Thu Feb 26 11:11:48 CST 2004


On Thu, Feb 26, 2004 at 06:53:09PM +0100, Thomas -Balu- Walter wrote:
> 
> Why? Because it would be easier for Skin coders to add special
> functionality. E.g. I needed to add some functions and variables into my
> skin and I am now loading the file to do so using a workaround: 
> <!--file:$PageTemplateDir/functions.inc.php-->
> as first line in my template file

Two thoughts: 
  1.  I think this "workaround" could become the standard method for
      doing this
  2.  If you want an alternate mechanism, write the skin instructions 
      such that someone does  include_once("pub/skins/myskin/myskin.php");
      instead of $PageTemplateFmt = 'pub/skins/myskin/myskin.tmpl', and
      let the skin's .php script handle the setting of $PageTemplateFmt.

I have no problem with either of the above conventions; still, I'm not
ready to adopt them as being the "distribution standard" until it's been
experimented with some more.

> I have no real idea how to do this, but I think that PmWiki might load a
> file pub/skin/SKINNAME/SKINNAME.php if it exists.  Skin-authors can then
> use it to set the template file variable and do other stuff (making sure
> that the site admin did not set the variables already?). 

The approach I listed in #2 above is probably sufficient to do this.
Most admins are going to be able to write an include statement (if told
what to write) just as easily as they can set a variable.

> BTW - Right now I have the odd effect, that I can set a global variable
> in my functions.inc.php which can be used in the template file:
> $GLOBALS['SubTitle'] = $GLOBALS['SubTitle'] + "barfoo";
> $GLOBALS['SubTitle2'] = $GLOBALS['SubTitle'] + "foobar"; 
> 
> I now can use $SubTitle2 and it will correctly display the set Subtitle
> plus "foobar", but if I use $SubTitle in the template it does not use
> the new value...

Ummm, why are you using the arithmetic '+' operator for strings anyway?  
Doesn't it just set the resulting values to zero?  But assuming you meant
'.' (concatenation)...

The problem may be that the FmtPageName routine caches global variable 
substitutions into an array to speed up the translation process, 
otherwise FmtPageName runs too slowly to generate pages.  So if you 
modify a global variable that's supposed to be used for a substitution, 
you sometimes also need to set $GLOBALS['GCount']=0 to get FmtPageName 
to refresh its variable cache.  I've tried to find ways around this in 
PHP or to have this happen automagically but haven't had any luck yet.

Pm



More information about the pmwiki-users mailing list