[pmwiki-users] Fox forms

Hans design5 at softflow.co.uk
Wed Jan 9 06:08:40 CST 2008


Wednesday, January 9, 2008, 12:02:34 AM, Sameer Kumar wrote:

> I would like to know if it is possible to edit data originally created
> with Fox by re-populating the original form and resaving it.

> Currently, every time the Fox form is submitted, a new instance of the
> data is added to the page.

Fox was designed to add content, and not to replace it.
I say "was", because I just uploaded a major upgrade, which indeed
allows replacement of content, using  a new foxaction "replace".
I still have to document all the changes though...

Fox was and is also able to do PTV updates.
So if your page contains data in form of page text variables, these
can easily be changed with use of a  fox form.

For this you specify the page as a ptv target, with the ptvtarget=
parameter (or hidden input field). You can specify the fields Fox will
attempt to update PTVs with the ptvfields= parameter (use a comma
separated list for several PTVs).

With the latest Fox version as of today, you can use in your fox form
the markup:
(:foxreplace template=TEMPLATEPAGE target=TARGETPAGE put=overwrite:)

which will replace any content of TARGETPAGE with the processed
TEMPLATEPAGE.

You can also target just a section of the target page, by using
anchors in the target page:
[[#section1]]
content....
[[#section1end]]

and then use the markup in your fox form like this:
(:foxreplace template=TEMPLATEPAGE target=TARGETPAGE#section1
put=overwrite:)

I added a new put= parameter to specify the location in the target
page, at which Fox shall add content (when using (:foxadd ...:)
instead of (:foxreplace ...:) or  (:foxcopy ...:)
For the 'replace' foxaction the put= parameter can be:
put=overwrite - replaces all content in the target (-section).
put=string - replaces first occurrence of a specific string given with
parameter mark=.
put=all - replaces all occurrences of  a specific string given with
parameter mark= .
put=marktomark - replaces content between two marks given with
parameters mark= endmark=
put=regex - replaces according to regex given. Use with care!! this may
still be buggy.

As you can imagine, 'replace' is a powerful action and allows deletion
of content, and even of whole pages. It needs to be specifically enabled
for the target page(s) in the FoxPagePermissions array.

From the above you can also see that Fox is now adding and replacing
content in  a target page by doing string replacements, i.e. it works
on strings now. Previously it worked on text lines only. The string
handling required a major rewrite of some functions. To enable better
multi page handling required rewriting several other functions.

The result is that one  can build more flexible Fox forms, which can
target different target pages using specific foxactions for each, ie.
you can use multiple sets of markups in your fox form like

(:fox-replace template=TEMPLATE1 target=TARGET1 :)
(:fox-add template=TEMPLATE2 target=TARGET2 :)
(:fox-add template=TEMPLATE3 target=TARGET3 :)
(:fox-copy template=TEMPLATE4 target=TARGET4 :)

The difference between 'copy' and 'replace' is that copy does not
do any template processing, the template is copied as is, whereas
replace does process the template.

I hope this helps for a start, but please ask more questions, and I
hope to document all new features soon as well.


  ~Hans




More information about the pmwiki-users mailing list