[pmwiki-users] page text variables in config.php

Jon Haupt jhaupt at gmail.com
Thu Feb 15 23:23:24 CST 2007


On 2/15/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Thu, Feb 15, 2007 at 10:34:06PM -0600, Jon Haupt wrote:
> > I read in the documentation that I have to define $PageTextVarPatterns
> > in config.php if I want to refer to a page text variable in
> > config.php.  I'm trying to write something that will force PmWiki to
> > determine which skin to use based on a page text variable.  I don't
> > think I understand the correct syntax for PageTextVar().  Why doesn't
> > this work?
> >
> > # special skin markup
> > SDVA($PageTextVarPatterns, array(
> >   'var:' => '/^:*(\\w[-\\w]*):[ \\t]?(.*)$/m',
> >   '(:var:...:)' => '/\\(:(\\w[-\\w]*):\\s?(.*?):\\)/s'));
> > $Blah = PageTextVar($pn,"Blah");
>
> ...where is $pn set?  (It needs to be the page for which
> you want to retrieve $:Blah.)
>
> Pm
>

Oops, yeah, thanks.  All I needed to do was

# special skin markup
SDVA($PageTextVarPatterns, array(
  'var:' => '/^:*(\\w[-\\w]*):[ \\t]?(.*)$/m',
  '(:var:...:)' => '/\\(:(\\w[-\\w]*):\\s?(.*?):\\)/s'));
$Blah = PageTextVar("$pagename","Blah");
if ($Blah == "1") $Skin = 'pmwiki';
else $Skin = 'whatever';

I think I had tried to use $pagename without the double quotes
initially, and started throwing in other terms hoping it would work.
It didn't occur to me until just now that I would need it to be in
quotes.

-j



More information about the pmwiki-users mailing list