[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
Sat Nov 5 04:51:44 CDT 2011

Dear Petko

thanks for pointing me to these recipes. I managed to configure EditAttributes with some quick and dirty javascript hacks to do the job. I noticed though, that there is a major bug in the recipe when handling checkboxes. it will only set the PTV to 1 once. if you want to set it to 0 again, it will ignore the unchecked checkbox leaving the PTV on a value of 0. also the recipe does not work with radiobuttons, select lists, etc without using a hidden helper form field and implementing all additional functionality with javascript hacks.

does the job more or less though.

thanks again,

brand & marketing

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

Aurikelweg 22
50259 Pulheim, NRW


On Nov/02, 2011, at 1800 , pmwiki-users-request at pmichaud.com wrote:

> Date: Tue, 1 Nov 2011 18:04:42 +0100
> From: Petko Yotov <5ko at 5ko.fr>
> To: pmwiki-users at pmichaud.com
> Subject: Re: [pmwiki-users] mod EditForm to parse certain directives
> 	and	preprend them to the content after submitting
> Message-ID: <201111011804.43089.5ko at 5ko.fr>
> Content-Type: Text/Plain;  charset="windows-1252"
> Hello. The EditAttributes recipe can be configured to do such additional form 
> fields, and it works even with existing pages.
>  http://www.pmwiki.org/wiki/Cookbook/EditAttributes
> 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.
>  http://www.pmwiki.org/wiki/Cookbook/PmForm
> 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.
>  http://www.pmwiki.org/wiki/Cookbook/Fox
> Petko
> 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