[pmwiki-users] httpvariables / markupexprplus

Dominique Faure dominique.faure at gmail.com
Fri Oct 24 07:33:23 CDT 2008

On Thu, Oct 23, 2008 at 20:45, noskule <noskule at gmx.net> wrote:
> hi list
> I expirienced a problem using httpvariables and markupexprplus.
> If I include httpvariables bevor markupexpr plus, setting pv's via {(set
> xx12)} is not working, if I include it after it works.
> dont work:
>    $EnableExprVarManip = 1;
>    include_once("$FarmD/cookbook/markupexprplus.php");
>    include_once("$FarmD/cookbook/httpvariables.php");
> work:
>    include_once("$FarmD/cookbook/httpvariables.php");
>    $EnableExprVarManip = 1;
>    include_once("$FarmD/cookbook/markupexprplus.php");

The HttpVariables recipe must appear first in order to be found and
handled by MarkupExprPlus.

> When I try do do the following condition:
>    (:if equal "{$?count}" "":)no count, setting to {(set count 20)}
>    (:else:){(setq count {$?count} )}(:ifend:)
> setting $count to 20 do not work if the condition is true, see:
>    http://test.netstreams.org/pmwiki/index.php?n=Main.WikiSandbox

This is but the expected behaviour...
...and here's why:

The page markup is processed by successive translation passes, each of
them being dedicated to a particular markup form handling. As the
Variable/MarkupExprPlus page markup is processed *before* the
conditional markup itself, the translation saw only two successive
assignment to the same variable:

  (:if equal "{$?count}" "":)no count, setting to {(set count 20)}
  (:else:){(setq count {$?count} )}(:ifend:)

MarkupExprPlus translation pass with ignored text enclosed in brackets:
  [(:if equal "] {$?count} [" "":)no count, setting to ] {(set count 20)}
  [(:else:)] {(setq count {$?count} )} [(:ifend:)]

Resulting in:
  {$?count} => nothing
  {(set count 20)} => {$count} set to 20
  {(setq count {$?count} )} => {(setq count )}
                            => {$count} set to nothing

This explains why I added the 'test' and the 'if' function, in order
to handle conditions during variable evaluations.
In your case, you should use

  {(set count (if (test equal "{$?count}" "") 20 {$?count} ))}

to get the expected result.


More information about the pmwiki-users mailing list