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

a.sonderhoff at gassi-tv.de a.sonderhoff at gassi-tv.de
Tue Nov 1 06:23:41 CDT 2011


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

-- 
ALJOSCHA SONDERHOFF
brand & marketing

office +49 2238 4629519
mobile +49 1511 5794189
fax    +49 2238 963023
email  <a.sonderhoff at gassi-tv.de>

GASSI-TV
Aurikelweg 22
50259 Pulheim, NRW
GERMANY

http://gassi-tv.de




More information about the pmwiki-users mailing list