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 being > saved (rather than browsed, previewed, etc)
Simon, it is hard to tell what you are trying to achieve with your recipe. Therefor it is hard to tell if it would be better to use page variables or page text variables, for instance. Much of the answers here have been fairly unspecific, and may not be 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 she edits the page content. If you want to restrict editing to adding or modifying a PTV in the page content, you could use a recipe like http://www.pmwiki.org/wiki/Cookbook/PTVReplace or follow its approach in your own recipe, or follow Peter's approach and use toolbox.php. To give you some overview on a specific mechanism, the PTVReplace works consists this: There is a markup defined for creating a (:ptvreplace ..:) link, which can take some parameters. On rendering the markup causes a 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 nothing else is happening. Clicking the link will cause pmwiki to run, and a custom action=ptvreplace in the url will instruct pmwiki.php to run a custom function,w hich will do the main work, in this cae opens the page, looks for the PTV, modifies it, saves the page and redirects to view the changed page again. For action=ptvreplace to work the recipe defines $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 through clicking the custom link, or may be through other means (form submissions, other ways of supplying the url with the parameters, cookie requests). A custom action via an entry to $HandleActions is one main way to hook a recipe into PmWiki. It may also be useful for calling custom test functions. You won't need special custom link markup, but instead you can create a standard link for instance like [[{$FullName}?action=myaction&key1=value1&key2=value2| do something]] so you got a link to click which will run your custom function via action=myaction. The function then can pick up the parameters in the link url via the $_GET variable. Hope this helps, sorry if I gone into too much detail which you may know anyway! Hans _______________________________________________ pmwiki-users mailing list [email protected] http://www.pmichaud.com/mailman/listinfo/pmwiki-users
