[pmwiki-users] httpvariables & markupexpressions

Martin Fick mogulguy at yahoo.com
Wed Apr 2 13:43:50 CDT 2008


--- Peter & Melodye Bowers <pbowers at pobox.com> wrote:

> > I try to use getvars within markup expressions.
> This seams not to work: > > See: 
http://netstreams.org/devel/cms/pmwiki/pmwiki.php?n=Main.WikiSandbox

....

> ===(snip from httpvariables - yes there are 2 almost
> identical rules)===
> # {$?!|@~var} http variable substitutions before
> {$var}
> Markup('{$?|!@~var}', '<{$var}',
>   '/\\{\\$([\\?\\!\\|@~])(\\w+)\\}/e',
>   "HttpVariables(\$pagename, PSS('$1'),
> PSS('$2'))");
> 
> # {$?!|@~var} http variable substitutions after
> {$var}
> Markup('{$?|!@~var}', '>{$var}',
>   '/\\{\\$([\\?\\!\\|@~])(\\w+)\\}/e',
>   "HttpVariables(\$pagename, PSS('$1'),
> PSS('$2'))");
> ===(snip)===
....
> I'm not familiar with having 2 rules like this in
> httpvariables...  In fact,
> the more I look at it (noting that the name is
> identical) I'm wondering if
> the 2nd doesn't overwrite the 1st?  That's a wild
> guess...  If that's the
> case then they both have their markup order
> specified as '>{$var}' and I
> don't know how pmwiki decides the order between the
> 2 -- probably something
> to do with when they are defined?

Ah yes, the name should have been changed to make this
work properly.  The intention is to allow
httpvariables to have pagevariables embedded within
them (missed by first rule) and vice versa (enabled by
first rule).

I do not believe this is the problem though (see
below)


> ===(snip from markupexpr)===
> Markup('{(', '>{$var}',
>   '/\\{(\\(\\w+\\b.*?\\))\\}/e',
>   "MarkupExpression(\$pagename, PSS('$1'))");
> ===(snip)===
> 

Unfortunately my test installation is pre
markupexpressions, so I will need to upgrade
it to test this.  But, thanks to Peter I can 
see from the above that the markup expressions
are defined to occur at the same time as the
second httpvariables rule: '>{$var}'.
My guess is that depending on when the
httpvariables.php script is loaded this may cause
different results.  In order to work as you want, 
and to also "fix the recipe" so that the problem
mentioned above is fixed, could you try changing the
ordering of the second rule from:

 # {$?!|@~var} http variable substitutions after
{$var}
 Markup('{$?|!@~var}', '>{$var}',
   '/\\{\\$([\\?\\!\\|@~])(\\w+)\\}/e',
   "HttpVariables(\$pagename, PSS('$1'),
   PSS('$2'))");

to:

 # {$?!|@~var} http variable substitutions before {()}
 Markup('{$?|!@~var}<{(', '<{(',
   '/\\{\\$([\\?\\!\\|@~])(\\w+)\\}/e',
   "HttpVariables(\$pagename, PSS('$1'),
   PSS('$2'))");


This change will ensure that the httpvariabels are
replaced before markup expressions.  To also enable
markup expressions inside of httpvariables (they are
not enable inside of pagevariables are they?), you
could then add a third rule like this:

 # {$?!|@~var} http variable substitutions after {()}
 Markup('{$?|!@~var}>{(', '>{(',
   '/\\{\\$([\\?\\!\\|@~])(\\w+)\\}/e',
   "HttpVariables(\$pagename, PSS('$1'),
   PSS('$2'))");

Probably overkill and I admit that this is probably
not the best way to go about achieving this (and I am
open to suggestions for improvements!), but I think
that it will work.  If there is not a better way to do
this, perhaps pmwiki could be modified to accept an
array of rules as an ordering rule (define a rule for
each of the orderings and append the ordering to the
name of the rule)?

-Martin



      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com




More information about the pmwiki-users mailing list