[pmwiki-users] Markup Processing Order

Patrick R. Michaud pmichaud at pobox.com
Sun Aug 20 17:55:28 CDT 2006


On Sun, Aug 20, 2006 at 05:03:09PM -0400, The Editor wrote:
> Hi Patrick!
> 
> Thanks again for the very encouraging help!  I decided to try for your
> second option as it seems more efficient to just process one small
> input string, one time, than to redo the whole page through several
> steps of processing.
> 
> However, it didn't work.  I've tried tinkering around with your code
> several different ways with no real results.  Here is the recipe as of
> my last attempt to process (:data Group.{$Name}:)
> 
> # Directive to retrieve data from another page
> Markup('fastdata', '<{$var}', '/\(:data(.*?):\)/ei', "ReadData('$1')");
> 
> # Function called by directive to retrieve form data
> function ReadData($l) {
>   global $WorkDir, $FmtPV;
> // print "datapage=$l;
>   $l = substr($l, 1);   // this gets rid of single blank space at beginning
>       $l = preg_replace('/\\{(!?[-\\w.\\/]*)(\\$\\w+)\\}/e',
>        "htmlspecialchars(PageVar(\$pagename, '$2', '$1'), ENT_NOQUOTES)");
> //  print "datapage=$l";
>   return
> }
> 
> Actually there's more but this works, for debugging.  When I uncomment
> the two print lines I get Group.{$Name} for the first $l and blank for
> the second.  If I switch the order to >{$var} I get Group.Page for the
> first $l and blank for the second. Either way the two lines of code
> you gave me seem to convert my input string to a blank.  

One problem may be that the $pagename variable isn't initialized
inside of the preg_replace call.  (Almost all of PmWiki's functions
pass $pagename as a parameter, this one doesn't.)  Perhaps adding
"global $pagename;" at the beginning will help.

> I'm
> struggling to make heads or tails of those two lines of code, so can't
> really begin to guess where the problem might be.  

These are exactly the lines of code in stdmarkup that cause
page variable substitutions -- i.e., they replace {$XYZ} with
the value of the XYZ page variable.

Pm




More information about the pmwiki-users mailing list