[pmwiki-users] Changing the Page Action on Page Load

Peter Bowers pbowers at pobox.com
Wed Sep 1 15:04:25 CDT 2010


On Wed, Sep 1, 2010 at 8:55 PM, Bruce & Ann Reidenbach
<bereiden at gmail.com>wrote:

> OK, so I have attempted to create a (:pageaction :) markup element, but I
> can't make it work.  I'm enough of a noob to not understand what the problem
> is.  I know that PageAction is being called because I stuck some debug
> strings in there and they were being displayed on the page.  It just appears
> that setting the action to text is not working properly.
>

By the time your Markup() rule is called it is too late to change $action
and make it have any effect.

PmWiki (in the big picture) does a bunch of configuration tasks and then it
checks the value of $action and calls an action handler function based on
the value of $action.  It is that action handler which then does everything
else, including processing all the rules, including the one you have put in
place.

Changing $action after the action handler is called is like shutting the
barn door after the horse is gone...

The way I would solve it would be to redirect to the same page but with a
different action=X parameter in the URL.  Make sure you check your $action
first to avoid an infinite redirect and also to still allow yourself to edit
the page, use diagnostics, etc.  If you want to get fancy you might want to
look into (:pageaction browse=mynewaction print=myprint edit=myedit:) type
of syntax which would allow mapping of various actions to other actions
(take a look at the ParseArgs() function if you decide to try to implement
this more generalized functionality).

I'm not personally seeing the utility of the rule, but the beauty of pmwiki
is its flexibility in allowing everyone to use it in their own way...

-Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20100901/c16dde48/attachment.html>


More information about the pmwiki-users mailing list