[pmwiki-users] thoughts on PTVs, (:include:) and editing forms

Hans design5 at softflow.co.uk
Tue Nov 13 18:42:57 CST 2007


Tuesday, November 13, 2007, 11:43:12 PM, DaveG wrote:

> How do you handle retrieving the wiki-text (ie the text to put in the
> textarea for editing), and saving it back and getting the page text (ie,
> the text to display on the web-page)?

The primary approach is now to use page text variables, and adding the
[[#NAME]] ... [#NAMEend]] syntax as a PTV pattern, so anchored
sections can be retrieved as PTVs. (To find a solution like this was the
purpose of this list thread). The retrieval works well with the
(:input defaults source=PageName:), as Pm suggested in this thread.

Saving the changes is done via the PTV update function in Fox.
The PTV fields named in the edit form will be updated and the page
saved with the updated text.

I still have not given up on a second approach, which can retrieve
page sections (anchor marked sections) by passing the pagename with
the section marker(s) to the TextSection function, which returns the
section, or the whole page, according to the anchors passed. This is
used to set a InputValues['text'] variable, with the effect that it
appears inside the edit textarea control named 'text', for editing.

In this case saving is not done via PTV update, but I use a new
text 'replace' routine for this: instead of inserting text content at
the bottom it replaces all. The trick is that it can act on the section,
so the rest of the page text is unaffected. Giving a pagename as
target, the 'replace' will replace all of the page text with the new
text from textarea. Giving a pagename with anchor will only replace
the section from anchor to next anchor. Or from anchor to another
anchor given. In a way it is similar than retrieving template
sections, only turned around to replace target sections.

To determine what shall be edited I created a new 'foxedit' link
markup: {[foxedit place]} in its simplest form, which appears as a link
labeled 'Edit'. Clicking it will use a foxedit action and pass onto
the handler function the pagename as target page and the place
parameter(s) as a section or a PTV name. The Edit function will call a
default Fox edit form, which appears 'on the page' (like the standard
edit form) by using the HandleBrowse function. After edit post
submission a redirect to the target page is issued, meaning the normal
page content will be visible again, with any updated content.

Different edit forms can be used by adding a form= parameter
to the link markup. And also a different link label can be given
inside the markup.

Actually the edit link can be used without the place parameter, most
useful when specifying a custom edit form for edits on PTV data, as
the custom form can have any number of input fields, corresponding to
PTVs, which will all be submitted and processed in one go.

I think that covers about the basic outline. This seems to work fine
now. But I am still testing and tweaking the way Fox handles multiple
target pages, especially how parameters get used, and which parameters
will act for individual target pages and which will remain general.

  ~Hans




More information about the pmwiki-users mailing list