This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| zref:wiki:pluginsyntax:pagemod [2025/04/22 13:44] – removed - external edit (Unknown date) 127.0.0.1 | zref:wiki:pluginsyntax:pagemod [2025/04/22 13:44] (current) – ↷ Page moved from wiki:pluginsyntax:pagemod to zref:wiki:pluginsyntax:pagemod Alan Shea | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== pagemod plugin ====== | ||
| + | ===== Overview ===== | ||
| + | |||
| + | I created [[doku> | ||
| + | |||
| + | When I saw the [[doku> | ||
| + | |||
| + | * A form exists on a page (created by the [[doku> | ||
| + | * A results placeholder sits on a page, this placeholder is enclosed by the **pagemod** tags | ||
| + | * The form is filled in and submitted inline with the [[doku> | ||
| + | |||
| + | That's really the functionality, | ||
| + | |||
| + | So here are the features: | ||
| + | |||
| + | * The form and the target can be the same page or different pages (i.e. a page can update itself or another page). | ||
| + | * Each **pagemod** enclosure has an id, so multiple forms can be used to update different parts of a page. | ||
| + | * The form can update multiple sections of a page. That is there can be multiple **pagemod** enclosures with different parts of the data in each, it will parse all of them as long as they have the same **id** as the submitting form. | ||
| + | * A person can update page that they **don' | ||
| + | * If want people to only have access to read the resultant page, but not change it, protect the **form** page. | ||
| + | * If you don't want people to have access to read the resultant page, deny them read access, then the form will also not work for them. | ||
| + | * FIXME (Does this mean they still have access to the form, but it generates an error when they try to use it?) | ||
| + | |||
| + | That's it. | ||
| + | |||
| + | ===== Usage ===== | ||
| + | |||
| + | ==== Examples ==== | ||
| + | |||
| + | Example Files can be found here: | ||
| + | |||
| + | * http:// | ||
| + | |||
| + | |||
| + | ==== Form Syntax ==== | ||
| + | |||
| + | Defining a form is done via the [[doku> | ||
| + | < | ||
| + | < | ||
| + | action pagemod <target page/ | ||
| + | |||
| + | < | ||
| + | submit | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | To make bureaucracy use the pagemod action, you need to add **action pagemod** with the following parameters: | ||
| + | |||
| + | * target : This is a page id which can include a namespace, so pagemod: | ||
| + | * pagemod_id : This is to identify which pagemod enclosures to translate | ||
| + | |||
| + | ==== Template Syntax ==== | ||
| + | |||
| + | Defining a pagemod template is done within a page with the following code: | ||
| + | < | ||
| + | <pagemod < | ||
| + | wiki text while will be parsed for transform tags like @@field from form@@ or ##field2 from form## | ||
| + | |||
| + | the contents of this section are invisible and will not show up on this page. | ||
| + | </ | ||
| + | |||
| + | some other wiki text | ||
| + | |||
| + | then some more | ||
| + | |||
| + | ^ table header 1 ^ table header 2 ^ | ||
| + | <pagemod table_adder output_before> | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | The pagemod enclosure starts with: | ||
| + | < | ||
| + | <pagemod < | ||
| + | </ | ||
| + | where the following is true: | ||
| + | |||
| + | * pagemod_id : This is the id of the pagemod. | ||
| + | * params : params are separated by , and can be one of the following: | ||
| + | * output_after : indicates that the output of the translation must come after the rewrite of the pagemod enclosure, the default is to output before the rewrite | ||
| + | * output_before : this is the default behaviour, to output the translation before the rewrite of the pagemod enclosure | ||
| + | |||
| + | The pagemod enclosure ends with the following: | ||
| + | |||
| + | </ | ||
| + | |||
| + | and the contents are not shown when the wiki page is viewed. | ||
| + | |||
| + | ** Since release 2009/10/12 ** There also exists the concept of meta variables, they are variables that are generated by the plugin at runtime. | ||
| + | |||
| + | * **@@meta.date@@** : The current date in dd/mm/yyyy | ||
| + | * **@@meta.datetime@@** : The current datetime according to ISO 8601 | ||
| + | * **@@meta.date.format.// | ||
| + | * **@@meta.user.id@@** : The user who submitted the form's username | ||
| + | * **@@meta.user.mail@@** : The users email address (if we know it) | ||
| + | * **@@meta.user.name@@** : The users full name (if we know it) | ||
| + | * **@@meta.page.id@@** : The full id of the page | ||
| + | * **@@meta.page.name@@** : The name of the page | ||
| + | * **@@meta.page.namespace@@** : The namespace of the page | ||
| + | |||
| + | New meta information tag requests should be sent to me for implementation. | ||
| + | |||
| + | > 2010-03-20 I added a auto-increment meta tag to your plugin. I needed it for a bug tracker/ | ||
| + | >> | ||
| + | ===== Conclusion ===== | ||
| + | |||
| + | Please let me know of any bugs or issues, requests. | ||
| + | |||
| + | ===== Feedback ===== | ||
| + | |||
| + | ==== Non-editable runtime values (ADDED 2009-10-12) ==== | ||
| + | |||
| + | We're using this plugin to log activity reports so I required the feature to include some non-editable runtime values like current date and user attributes in pagemod' | ||
| + | <code diff> | ||
| + | 13a14 | ||
| + | > | ||
| + | 32a34,41 | ||
| + | > | ||
| + | > | ||
| + | > | ||
| + | > | ||
| + | > | ||
| + | > | ||
| + | > | ||
| + | > | ||
| + | </ | ||
| + | I've no experience in PHP so maybe this solution isn't optimal but it does work :-) --- [[lost@infidel.name|Dmitry Rubinstain]]. | ||
| + | |||
| + | ** From Author : This is now possible using the meta tags described in the documentation above ** | ||
| + | |||
| + | ==== Autodetect current page id (ADDED 2009-10-12) ==== | ||
| + | |||
| + | This plugin rocks ! IMHO, it provides such great features that it should be advertised on the front page. I'm planning to use it as a commenting system. Would it be possible to auto-detect the current page id (like the [[doku> | ||
| + | |||
| + | < | ||
| + | action pagemod auto new_comment | ||
| + | fieldset "Add your comments below" | ||
| + | textbox | ||
| + | select | ||
| + | textarea " | ||
| + | submit | ||
| + | </ | ||
| + | |||
| + | It would save an incredible amount of time when you have to insert forms in many pages ! --- //Laynee 2009/10/05 16:22// | ||
| + | |||
| + | ** From Author : This is now possible using the _self target described in the documentation above ** | ||
| + | |||
| + | Woohooh! The new version works like a charm ! Thank you very much :) --- //Laynee 2009/10/12 16:00// | ||
| + | |||
| + | ==== Minimalistic Guestbook ==== | ||
| + | I used this plugin for a minimalistic guestbook. Although my wiki can be edited by everyone, I think visitors would be more willing to leave a message through a little form. See http:// | ||
| + | < | ||
| + | ====== Guestbook ====== | ||
| + | ===== New Comment ===== | ||
| + | < | ||
| + | action pagemod _self add_comment | ||
| + | fieldset "Write new comment" | ||
| + | textbox | ||
| + | email "Email (optional)" | ||
| + | textarea " | ||
| + | submit | ||
| + | </ | ||
| + | |||
| + | ===== Comments ===== | ||
| + | <pagemod add_comment output_after> | ||
| + | // | ||
| + | ^< | ||
| + | |< | ||
| + | </ | ||
| + | </ | ||
| + | --- //M. 2010/04/02 03:17// | ||
| + | |||
| + | ===== Fixed Bugs (And won' | ||
| + | |||
| + | ==== Error message in combination with bureaucracy plugin ==== | ||
| + | |||
| + | Hi, I installed pagemod together with the bureaucracy plugin, but I can't get them to work. After submitting data through a bureaucracy form (e.g. the demo-page) I receive the following error: | ||
| + | |||
| + | Fatal error: Class ' | ||
| + | |||
| + | What am I doing wrong? I tried this on DokuWiki 2009-12-25c as well as on older versions, with same error. | ||
| + | |||
| + | > | ||
| + | |||
| + | >Replace in the file bureaucracy/ | ||
| + | < | ||
| + | // run through fields and prepare replacements | ||
| + | foreach($data as $opt) { | ||
| + | $label = preg_quote($opt-> | ||
| + | $value = $opt-> | ||
| + | if(in_array($opt-> | ||
| + | $label = preg_replace('/ | ||
| + | $patterns[] = '/ | ||
| + | $values[] | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | >> I tried both solutions above, but still remain with the same error. Something else I might be missing? --- // LWolf 2010/02/25 // | ||
| + | |||
| + | >> Its a type syntax_plugin_bureaucracy_actions needs to be replaced by syntax_plugin_bureaucracy_action. At least, this worked for me --- //Gerione 2010/3/4// | ||
| + | |||
| + | >> I have the same big problem ! Help me please :-( --- // | ||
| + | |||
| + | >> **THE SOLUTION** = //Rdemont// + // | ||
| + | |||
| + | ** From Author : Fixed, now working with the new bureacracy, thanks for the help. ** | ||
| + | |||
| + | ==== Multiple forms on one page (RESOLVED) ==== | ||
| + | |||
| + | Multiple forms + pagemod sections on one page (and not only, read more) do not work. | ||
| + | |||
| + | **Scenario 1**: I have one page (name it: '' | ||
| + | * each pair with different id (exactly: '' | ||
| + | * both pairs identical otherwise (same fields, same structure). | ||
| + | |||
| + | **Scenario 2**: I have one page with form ('' | ||
| + | * each pair with different id (exactly: '' | ||
| + | * both pairs forms/ | ||
| + | |||
| + | In both scenarios, data gets added to both datasets, instead of one of them ('' | ||
| + | |||
| + | **From Author : This is not a bug in this module, its a bug in bureaucracy. | ||
| + | |||
| + | **< | ||
| + | |||
| + | **From Author : This bug appears to have been fixed, many thanks to the bureaucracy maintainer for this** | ||
| + | |||
| + | ==== small bug for @@meta.user.id@@ | ||
| + | Great plugin ! I use it all the time. small bug for @@meta.user.id@@ which doesn' | ||
| + | I think it should use //return $INFO[' | ||
| + | |||
| + | **From Author : I cannot replicate this, both accessors work ** | ||
| + | |||
| + | >> 2011-11-15 From besancon@math.jussieu.fr: | ||
| + | return $INFO[' | ||
| + | to | ||
| + | return $INFO[' | ||
| + | |||
| + | ==== Question on Period Use in Field Name ==== | ||
| + | |||
| + | I was wondering if there is a way to use the period in field names, so you could make numbered items like "1. What is your name?", | ||
| + | |||
| + | On the other hand, is there any way to show a field title like " | ||
| + | |||
| + | ** From Author : Fixed in 1.2 ** | ||
| + | |||
| + | ==== Is it possible to check the value of a placeholder? | ||
| + | |||
| + | Hi! I am quite new to wikis, so please forward me to the right place if my question is wrong here. Is there any way to check the value of a placeholder and treat the form depending on its value? Something like "if @@name@@==' | ||
| + | |||
| + | ** From Author : This isn't functionality I am looking at adding, because its open ended in terms of possibilities ** | ||
| + | |||
| + | |||
| + | |||
| + | ==== Shows an empty screen after submitting the form ==== | ||
| + | |||
| + | After I submit the form the page reloads but shows only the header, footer and sidebar without the content. | ||
| + | The results output doesn' | ||
| + | |||
| + | The other bureaucracy actions (email and template) work fine. | ||
| + | |||
| + | >>I have the same problem and I can't find any solutions on this page. I would like to add that my DokuWiki is hosted on a " | ||
| + | |||
| + | >>The same happens here, just a blank page after submit when using the " | ||
| + | |||
| + | ** From Author : I cannot replicate this even using the latest software, | ||
| + | |||
| + | ** From Author : This has been confirmed fixed by the bug raiser, no idea what I did, but nevertheless the bug has moved on ** | ||
| + | |||
| + | ==== Drop-down Boxes ==== | ||
| + | |||
| + | I already asked this on the bureaucracy page but maybe it could be implemeted here. Is there a way to use multiple drop-downboxes where the input in the first box affects which options are available in the 2nd one and so on? Thanks! - Paul | ||
| + | |||
| + | **From Author - This will have to be done in the bureaucracy plugin, I don't have much to do with the front end.** | ||
| + | |||
| + | ==== Multiple actions ==== | ||
| + | |||
| + | When looking for the possibility of using both mail and pagemod actions from the same form, I came across a small extension to the pagemod plugin, namely the ' | ||
| + | |||
| + | To install, add the following piece of code as a file named ' | ||
| + | < | ||
| + | <?php // charset=utf-8 | ||
| + | /** | ||
| + | * Action pagemod followed by sendemail for DokuWiki plugin bureaucracy | ||
| + | */ | ||
| + | |||
| + | class syntax_plugin_bureaucracy_action_pagemodandmail extends syntax_plugin_bureaucracy_action { | ||
| + | |||
| + | /** | ||
| + | * Simply extract the relevant arguments and call the relevant actions | ||
| + | */ | ||
| + | function run($data, $thanks, $argv) { | ||
| + | global $ID; | ||
| + | global $conf; | ||
| + | require_once(DOKU_PLUGIN . ' | ||
| + | require_once(DOKU_PLUGIN . ' | ||
| + | require_once(DOKU_PLUGIN . ' | ||
| + | |||
| + | $pagemodargs = array_slice($argv, | ||
| + | $emailargs = array_slice($argv, | ||
| + | |||
| + | $class = ' | ||
| + | $pagemodder = new $class(); | ||
| + | $pagemodsuccess = $pagemodder-> | ||
| + | |||
| + | $class = ' | ||
| + | $emailer = new $class(); | ||
| + | $emailsuccess = $emailer-> | ||
| + | |||
| + | $rmsg = ''; | ||
| + | if (!$pagemodsuccess) {$rmsg .= " | ||
| + | if (!$emailsuccess) {$rmsg .= " | ||
| + | if ($rmsg=='' | ||
| + | else {return $rmsg.join(',', | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Use the following notation in the form: | ||
| + | < | ||
| + | action pagemodandmail < | ||
| + | </ | ||
| + | Example: | ||
| + | < | ||
| + | < | ||
| + | action pagemodandmail support: | ||
| + | Thanks " | ||
| + | Fieldset "Error report" | ||
| + | Textbox | ||
| + | email " | ||
| + | select " | ||
| + | textarea " | ||
| + | textarea "Error message(s)" | ||
| + | submit "Send report" | ||
| + | </ | ||
| + | </ | ||
| + | The page support: | ||
| + | < | ||
| + | ^ Name ^ Subsystem ^ Description ^ Error message(s) ^ | ||
| + | <pagemod buglist output_before> | ||
| + | </ | ||
| + | // [[knutsd@met.no|Knut S. Dale]] 2010/12/27 // | ||
| + | |||
| + | ==== Multiple Pages changed from one form ==== | ||
| + | |||
| + | Would such syntax be possible: | ||
| + | |||
| + | < | ||
| + | < | ||
| + | action pagemod _self, | ||
| + | fieldset " | ||
| + | textbox " | ||
| + | date " | ||
| + | date " | ||
| + | textarea | ||
| + | submit " | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | making it possible to have one form which places the info on more than one page? - Andy | ||
| + | |||
| + | ===== Bugs ===== | ||
| + | |||
| + | * I experienced this: if the %%@@Variable@@%% is on the begining of the line, it allways expand into empty string, even if I fill the form. And I found another difference - with bureaucracy template mode, not filled variables were kept as were, but with pagemod mode, they are replaced with empty strings. | ||
| + | * Use of plugin is problematic if you use it with tables AND use '' | ||
| + | * Is there a size/length constraint? | ||