[pmwiki-users] mod EditForm to parse certain directives and preprend them to the content after submitting

Petko Yotov 5ko at 5ko.fr
Tue Nov 1 12:04:42 CDT 2011

Hello. The EditAttributes recipe can be configured to do such additional form 
fields, and it works even with existing pages.


While editing, it removes the (:title ... :), (:myPTV: ... :) and other 
configured strings from the page text and places them in additional text boxes 
(not sure if it can do drop-down select lists). After submitting the changes, 
it compiles the page again, with all variables at the end of the page text.

The other recipe that can edit PageTextVariables is PmForm. It can edit 
PageTextVariables (it adds them if they are not in the page) and it can add 
text in a page, like from a template. Standard pmwiki forms are used as edit 
forms, so there is some configuration to do.


There is also the Fox recipe. I have never had the chance to use it or review 
it, but it seems to do these kinds of things and more.



On Tuesday 01 November 2011 12:23:41, a.sonderhoff at gassi-tv.de wrote :
> Dear PmWiki community,
> I am looking for a way to modify the edit form (preferably by writing a new
> Cookbook recipe) to be a little more n00b-friendly. ^_~ on gassi-tv.de we
> are using a lot of directives (variables and page text variable
> declarations) to control certain modules, e. g. whether the FB Like Button
> or FB Comments show up on a site or not, where the video and poster files
> for a certain vodcast are, title, description, keywords and stuff like
> that.
> that means there are quite some lines of directives on an average page,
> which also means, that it needs certain training level to actually edit
> the content without screwing something up by accident.
> what I am looking to do (inspired by the EditForm Custom Fields recipe) is,
> to have form inputs (text fields, text areas, dropdowns, etc) for all of
> the commonly used directives without changing the way PmWiki essentially
> works. EditForm Custom Fields for example disables the (:title … :)
> directive and sets a new title field. this might be the more sophisticated
> approach, but is basically unusable for sites with a lot of already
> existing pages.
> so what I want to do is some regex which extracts the particular directives
> from the content and shows them as dedicated form inputs. after submitting
> these form input values should be prepended in form of directives to the
> content.
> example:
> (:DirectiveA: VALUE:)
> !! content
> should show up in edit form as
> DirectiveA: [input_field name=DirectiveA]
> Text: [textarea name=text id=text]
> [submit_button]
> after submitting, "DirectiveA" and "Text" are re-merged with the directive
> prepending the content of "Text".
> I can think of two ways to do this:
> 1) The Quick and Dirty JS way
> have client-based JS run the regex and inject additional form input fields,
> hijack the submit button and have the JS merge all before submitting into
> the "text"-textarea. as this is nothing PmWiki specific, I already know
> how to do this, and what the downsides are (limited processing power on
> mobile devices, fallback compatibility with NoScript/JS-disabled browsers,
> IE-specific workarounds).
> 2) write a real cookbook recipe
> that's basically what I prefer to do and need some ideas and pointing in
> the right direction. I do know how to declare form fields in PmWiki with
> "SDVA($InputTages['…'], array…", but I basically haven't the slightest
> idea how the forms are processed into the file based database system after
> submitting.
> Thanks for any replies in advance and happy brainstorming.
> —Josh

More information about the pmwiki-users mailing list