[pmwiki-users] Conditional Extensions

Dominique Faure dominique.faure.1 at free.fr
Thu Sep 15 16:44:08 CDT 2005


At Thursday, September 15, 2005 11:22 PM [GMT+1=CET], Martin Fick wrote:

> Has there been any thought to creating conditional
> extensions that would include == and != ?
>
> I know that for most conditions this is not needed since a
> conditions typically imply ==.  But, I am working on an
> extension which would create many new variables and did not
> think it very elegant to have to create a condition for
> each one of these variables? i.e.
>
> A few variables I will create --  conditions needed
>
> {$PageList.Name}                  pagelist.name
> {$PageList.Group}                 pagelist.group
> {$PageList.PageCount}             pagelist.pagecount
> ...
>
> I have about ten of these.
>
>
> It would seem much more elegant to simply create the variables
> on the right and then to use a condition such as
>
> (:if {$PageList.Group} == Photos :)
>
> instead of
>
> (:if pagelist.group Photos :)
>
> I realixe this is not the pmwiki way; is that because it is
> considered too complicated, or somehow open to abuse?
>
> Does anyone have any thoughts on this?

Current conditional implementation could not handle such syntax.

>
> Also any thoughts on ways to nest conditions?
>

You should have a try on the Cookbook/ConditionalExtensions recipe which 
implements complex boolean expressions.

if A then
  if B then
    something
  else
    something else
  endif
endif

is equivalent to:

if A and B then
  something
elseif A and not B then
  something else
endif

which could be easily written with the related recipe.

Regards,
Dom 





More information about the pmwiki-users mailing list