[pmwiki-users] Case of vanishing FmtPV

Ben Stallings Ben at InterdependentWeb.com
Mon Sep 18 08:26:45 CDT 2006


Caveman asked me in private e-mail how I did custom variable markup for 
SelectQuery, and then posted this to the list:

> Actually, now that I think about it, another option is to write a
> simple custom markup, as I seem to have no problem getting the text
> back through the return function.  Maybe that's as easy as anything.
> Yeah, why didn't I think of that before!
> 
> Still--it really irks me why this page variable wouldn't set.  I can't
> even think of a POSSIBLE explanation for the behavior...  Any
> thoughts, anyone?

The way I did it for SelectQuery -- and I stress again that this is a 
kludge I'd like to get rid of in a future version -- was to use a 
different global variable, $SQdata, instead of $FmtPV, and then 
introduce this {`fieldname`} markup:

Markup('databasefield', 'inline', "/{`(.*?)`}/e", "DatabaseField('$1')");

function DatabaseField($fieldname) {
  global $SQdata;
  return nl2br($SQdata[$fieldname]);
}

Clearly this is pretty straightforward.  So I can only guess that the 
reason $FmtPV works differently is that the page-variable markup is 
handled differently -- either it's processed at an earlier time than the 
cookbook recipes in question, so that the variable has not yet been set, 
or it's running some other function on the value before returning it. 
(nl2br just changes newlines to <br> tags)  I didn't have any luck 
tracking it down, but maybe this clue will help you do so, Caveman, so 
that you don't have to repeat my kludge in your own recipe!  --Ben




More information about the pmwiki-users mailing list