Monday, September 28, 2009, 5:43:30 AM, Simon wrote


Is there a way I can test and only do this if the page is bein

saved (rather than browsed, previewed, etc


Simon, it is hard to tell what you are trying to achieve with you

recipe. Therefor it is hard to tell if it would be better to use pag

variables or page text variables, for instance

Much of the answers here have been fairly unspecific, and may not b

too helpful for what you really trying to accomplish


For instance your question above: I have to guess what you mean

Just on what you say, I am tempted to answer

If a user edits a page, she can add a PTV, or modify a PTV, when sh

edits the page content

If you want to restrict editing to adding or modifying a PT

in the page content, you could use a recipe lik

http://www.pmwiki.org/wiki/Cookbook/PTVReplace

or follow its approach in your own recipe, or follow Peter's approac

and use toolbox.php


To give you some overview on a specific mechanism, the PTVReplace work

consists this

There is a markup defined for creating a (:ptvreplace ..:) link

which can take some parameters. On rendering the markup causes 

function to run, which produces valid HTML output for the link

including the parameters as part of the url the link targets


So when a user browses the page, she can see the link, but nothin

else is happening. Clicking the link will cause pmwiki to run, and 

custom action="" in the url will instruct pmwiki.php to ru

a custom function,w hich will do the main work, in this cae opens th

page, looks for the PTV, modifies it, saves the page and redirects t

view the changed page again


For action="" to work the recipe define

$HandleActions['ptvreplace'] = 'PTVReplace'

PTVReplace is the name of the custom function doing all the work


So we got a markup function creating link HTML, and a 'Handle Action

function to run when the custom action is evoked, whichmay be throug

clicking the custom link, or may be through other means (for

submissions, other ways of supplying the url with the parameters

cookie requests)


A custom action via an entry to $HandleActions is one main way t

hook a recipe into PmWiki. It may also be useful for calling custom tes

functions. You won't need special custom link markup, but instea

you can create a standard link for instance lik


[[{$FullName}?action="" do something]


so you got a link to click which will run your custom function vi

action="" The function then can pick up the parameters in th

link url via the $_GET variable


Hope this helps, sorry if I gone into too much detail which you ma

know anyway


Hans

_______________________________________________
pmwiki-devel mailing list
pmwiki-devel@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-devel

Reply via email to