|
Cookbook /
ConditionalExtensionsSummary: A Conditional Markup extension for PmWiki 2.x
Version: 20061028
Status: Stable
Prerequisites: pmwiki-2.0.beta36
Maintainer: Dfaure
Categories: Markup
Download: extendcond.phpΔ
Question answered by this recipeI've found the ConditionalMarkup very powerful, but how do I handle more complex expressions involving string/number comparisons, pattern/pagename matching and/or several simultaneous conditions ? DescriptionDownload extendcond.phpΔ, save it in the cookbook directory and add:
Notes and CommentsThe recipe script provides extras conditional markup verbs to handle regular boolean expressions and string/number comparisons. String/Number comparisons
Strings containing spaces may be enclosed between quotes.
All these condition verbs may be given with a trailing ' Pattern/Pagename matching
Boolean expressionsThe boolean expressions extension defined by this recipe has been integrated into PmWiki core since v2.1.0beta33: The related recipe code part does not interfere with the latest core implementation. Following forms are equivalents: (:if expr BOOLEAN_EXPRESSION :) (:if [ BOOLEAN_EXPRESSION ] :) (:if ( BOOLEAN_EXPRESSION ) :) The "
With A and B being either regular conditions (see ConditionalMarkup) or bracketed boolean expressions of regular conditions. Warnings
SampleWith the code below:
(:if expr auth admin || auth attr || auth edit :)
[[Logout -> {$Name}?action=logout]] %green%{$Author}%%
(:if:)
you get a logout link followed by the current author name available only when authentified with higher than 'read' right. ContributorsSee AlsoRelease Notes
SandboxSome boolean tables:
CommentsIn my wiki this: (:if ( ! {$:Val} ) :)false(:else:)true(:if:) returns true. Val is unset, so why isn't it false? But even by writing (:Val::), (:Val:0:), or (:Val:false:) it keeps returning true. Nick - 2007.12.19 ps. is there no way to nest conditions? maybe with some cookbook recipe I haven't discovered yet? It's not the same as conditional markup, but conditional markup expressions are possible via WikiSh.php Peter Bowers March 23, 2008, at 06:12 AM |