[pmwiki-users] using PTVs as shortcuts for conditionals
Patrick R. Michaud
pmichaud at pobox.com
Tue May 29 17:07:52 CDT 2007
On Tue, May 29, 2007 at 04:34:10PM -0500, Ben Stallings wrote:
> (:if condition 1:)
> message 1
> (:else if condition 2:)
> message 2
> (:else if condition 3:)
> message 3
> (:else if condition 4:)
> message 4
>
> and I want a whole bunch of other stuff (including pagelists, which have
> their own conditionals and so end any conditionals in the containing
> page) to happen only if all of those tests are false. So I followed
> message 4 with this:
>
> (:flag: yes:)
>
> so that rather than testing conditions 1 through 4 over and over again I
> could just test for
>
> (:if equal {$:flag} "yes":)
>
> ... but it doesn't work. Are all the conditionals on the page evaluated
> before all of the page text variables? That can't be right, because I
> can use other page text variables in conditionals... so where is the
> proverbial rub? --Ben
One cannot use (:if:) directives to conditionally set page text
variables. When PmWiki goes to read the value of a page text variable
from a page's text, it doesn't try to evaluate the other markups
on a page, such as (:if:). It just looks for things that match
the page text variable patterns, and returns whatever it finds.
Also, this probably is unrelated, but in general you would want
to write
(:if equal "{$:flag}" "yes" :)
because otherwise an empty $:flag variable wouldn't appear in the
(:if:) directive.
Hope this helps,
Pm
More information about the pmwiki-users
mailing list