[pmwiki-devel] PmWiki request

The Editor editor at fast.st
Tue Dec 12 08:24:26 CST 2006

On 12/12/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> Seems to me that
>  (:if exists parameter:)(:input hidden action:)(:if:)
> is only few characters longer but more consistent.  Plus you
> get complex expressions for free.

Actually this is not equivalent to what I'm wanting to do at all.
(This was also Hans misunderstanding I believe).  What I want to do
rather is perform certain ZAP functions AFTER the form submits based
on the values entered.  It has nothing to do with markup.  So for a
more basic example I might add these lines to a form (May need to
change the syntax...):

(:input text newpage :)
(:input ifexists "newpage|warn:Page already exists":)

In this case the input fields must be created by markup so I can POST
the 'text' and 'ifexists' values on submission.  Those values are
submitted like any other form field with no conditional activity
taking place. Afterwards, when ZAP begins processing the POST values,
it eventually comes to $_POST[ifexists] and says, ok lets see if
"exists $_POST['newpage']" is true or false.  If true, stop form
processing and return warning message to the browser.  If it fails
form processing continues.  There is absolutely no change at the
markup level, only at the forms processing level.

There is another approach to conditionals in zap already but it was
extremely limited, had strange syntax, and was complex.  In fact I
doubt anyone has even tried it yet...  :)  By tapping into PmWiki's
conditional testing system however, it 1) becomes far more flexible
and powerful, and 2) uses more familiar syntax.  Its still an
experimental approach but got stuck in my testing on figuring out how
to get the t/f values.  Once I can get a demo up it may be more clear
what I'm talking about.

> > My question is this:  What function do I call to get the true/false
> > returned to me.  I've looked at these two possibilities:
> >
> > function CondExpr($pagename, $condname, $condparm) {
> > function CondText($pagename,$condspec,$condtext) {
> >
> > But to be honest, I can't make much heads or tails of either of them,
> > but dont' think either will work for what I need, as they seem to be
> > locked into returning markup only.  Is there someway PmWiki could be
> > rewritten slightly to break out the part that determines if true or
> > false into a separate function?  Or if what I need already exists,
> > could someone point the way?
> The CondExpr() function returns true or false depending on the
> expression passed in $condparm.  So, it already does what you're
> asking for.
> The CondText() function can also do exactly what you're asking
> here, and is more general.  The $condspec parameter is the
> conditional part of the (:if:) directive, the $condtext parameter
> is what to return if the conditional part is true.  (If the conditional
> is false, CondText() returns an empty string.)
> So, if you want to use CondText as a true/false indicator, simply
> use 'true' as the $condtext parameter:
>    if (CondText($pagename, $condition, true)) ...
> To illustrate using the condition of your original post:
>    $condition = "expr exists Group.Name && ! exists OtherGroup.Name";
>    if (CondText($pagename, $condition, true)) {
>      ## Group.Name exists and OtherGroup.Name doesn't
>      ...
>    }

OK, great Pm!  This is exactly what I want.  I'll give it a whirl and
see if I can't get it to work for me.  Thanks for helping again!


More information about the pmwiki-devel mailing list