Back to FoxEdit

Leave latest comments/questions at the top please!

Hi Hans
i'm having trouble with FoxEdit on a site that had working FoxEdit code - visitors have been using a FoxEdit link successfully to leave comments on pages for years. But now, after updating to the most recent version of PmWiki (from a very old version), and also updating FoxEdit from v2009 to v2012, it's no longer working as expected. here is what i'm experiencing:

My FoxEdit link looks like:

  {[foxedit #CommentSection label="{$addCommentLink}" form={$EditSectionForm_Comments}]}
  note: {$EditSectionForm_Comments} is just shorthand for FoxTemplates.EditSectionCommentForm

My original FoxTemplates.EditSectionCommentForm that's worked for years contains some of the following code:

(:fox editform put=bottom template=FoxTemplates.FoxCommentTemplate target="{$EditTarget}#{$EditSection}" redirect="{$EditTarget}#comments":)
(:foxptv ptvtarget={$EditTarget} ptvfields="{$EditSection}" ptvfmt=section :)\
(:input hidden csum '{*$LastModifiedSummaryListAllRecent}':)\

Now it results in the comment text being posted on the page, but not within the #CommentSection. i.e. I see this output:

#foxbegin ...#
my test message
#foxend ...#


I partly solved this by changing target="{$EditTarget}#{$EditSection}" to target="{$EditTarget}{$EditSection}" (no # between sections), and the result was 1/2 positive – the comment text now gets successfully pasted inside the #CommentSection & #CommentSectionend anchors – BUT two new anchors are now being pasted into the page, i.e.:

#foxbegin ...#
my test message
#foxend ...#


I'm a bit baffled and wondering if something was changed in recent iterations of Fox, FoxEdit, or PmWiki, that might be causing this?

Below is a printout of part of the debug transcript from Fox:

$fx Array
    [n] => MyGroup/MyPage
    [foxpage] => MyGroup.MyPage
    [action] => foxpost
    [foxname] => editform
    [put] => bottom
    [template] => FoxTemplates.FoxCommentTemplate
    [target] => MyGroup.MyPage#CommentSection
    [redir] => MyGroup.MyPage#comments
    [:target] => Array
            [0] => MyGroup.MyPage

    [:template] => Array
            [0] => 

    [:if] => Array
            [0] => 

    [:put] => Array
            [0] => 

    [:mark] => Array
            [0] => 

    [:endmark] => Array
            [0] => 

    [:ptvfields] => Array
            [0] => #CommentSection

    [:ptvfmt] => Array
            [0] => section

    [:ptvclear] => Array
            [0] => 

    [:foxtemplate] => Array
            [0] => 

    [:ptvtarget] => Array
            [0] => MyGroup.MyPage

    [:foxaction] => Array
            [0] => ptv

    [csum] => New Comments added!! 
    [scoretitle] => MyPage
    [commentNotify] => comment
    [dateUNIX] => 1360889102
    [foxsessionID] => 2c24f15314f2d99bb91df28e5e5aec90
    [foxnotify] => MyGroup
    [comment] => test4
    [author] => test
    [post] => Save
    [chk_name] => Array
            [0] => author,comment

    [chk_msg] => Array
            [0] => required field

Thanks for the help!
overtones99 February 14, 2013, at 07:30 PM

I guess this may be caused by the (:foxptv ...:) markup creating an empty section. Do you need this markup at all? You set target and ptvtarget, one should be enough to receive the comment? - HansB February 15, 2013, at 03:06 AM

that did it! thanks Hans! overtones99 February 15, 2013, at 08:34 PM

First, I want to say that Fox is a wonderful extension to PMWiki!! I use it extensively.
I am wondering whether there is an easy way, with FoxEdit, to show the edit page inline, without the need of the FoxEdit link. Something along the lines of (:include...:), but without the need to specify all the PTVs that are to be passed along.

I do not understand what you are trying to do. You don't want a link which opens content in an edit form?

Also, I am looking for a way to use FoxEdit with a checkbox array. I cannot seem to get the Form to SELECT the checkboxes that are actually selected. The values get saved to the PTV as an array, but the form does not select them.
On a similar note, even with checkboxes that are not part of an array, clearing the checkbox does not clear the PTV, even though I am using ptvclear.


I can't advise you on this without seeing a form example. Can you email this to me? Or post it here, but pleae abbreviated with just the relevant part. HansB October 07, 2011, at 02:16 AM

Hi, I've got the automatic Edit links installed as described. The problem is that when I save an edited section, the anchor is not saved with the text, so the edit link disappears. It's like a one-time usage. In the EditSectionForm, the anchor doesn't show up in the textarea...

What can I do? Thanks!

Try with latest version foxedit.php. Note also the different default location of edit forms. I also tightened the foxedit anchor markup (which creates automatic dynamic foxedit links) to include a minus sign in front of digits, like [[#section-123]] - HansB August 10, 2011, at 07:46 AM

Hi Hans, I have a problem. When i make a link {[foxedit #ab ]} (i use the example form) for editing section, the edit section do not stop at [[#abend]], it continues until the end of the page, or, until an anchor wich is named #foxend ...#. Do you have an idea ? Thanks a lot for your help Benji June 09, 2011, at 06:28 PM

No warning or flagging of simultaneous edits

Foxedit, unlike standard PmWiki editing, does not warn the user about conflicting concurrent edits. For example if I open a section to edit, and get called away, then return to complete the edit, everything that anyone else has entered in that section in the interim will be lost with no warning or flagging of the conflicts. Is there a way to make Foxedit handle simultaneous edits the same way PmWiki does? If not, is there a way I can make it at least warn the user that something was overwritten? - RandyB December 4, 2009 at 11:49 AM.

?action=foxedit&section=... not showing up when Previewing

Hi - While updating a PTV or section using FoxEdit (at Group/Name?action=foxedit&section=...), I've noticed that after hitting the Preview button, the URL changes back to the original, shortened URL - (Group/Name) - without the ?action and ?section info appended. This is problematic as I have a handful of instructional texts that should appear at the top of the page which are only supposed to display on their respective section pages (i.e. (:if equal {$?section} Section2:), then display instructionSet2). Is there a way to have the URL remain Group/Name?action=foxedit&section=... even when Previewing?
Thanks, overtones99 May 22, 2009, at 07:02 AM

Preview is handled by fox.php (in function FoxHandlePost) and uses the foxaction 'display'. The FoxEdit form has the Preview button and some Preview section (or should have if you want a Preview). I cannot see that you can change the url. But perhaps you can change the Preview section on the edit form, and/or use a (:foxpreviewtemplate "...":) markup, like the foxtemplate markup, which Fox will use for the preview. - HansB

#Section creation with FoxEdit

Hi. While using FoxEdit, if a {$:PTV} does not yet exist, but a link to it is added to the page, clicking the FoxEdit-link will automatically create and append the PTV to the bottom of the page. If a similar FoxEdit-link is made for a non-existent [[#section]], upon clicking the link nothing happens, and no new section is created. Is this the expected reaction? Is it possible to create non-existent #sections via a link the same way one would for a PTV? if not, why?
thanks, overtones99 May 10, 2009, at 08:03 PM

The creation of a not-yet-existing PTV is done by Fox, not FoxEdit. The hidden PTV is the default format. You can specify other formats in the Fox form (in your case the edit form called by FoxEdit) by adding a 'ptvfmt' parameter to thew fox markup: ptvfmt=section will tell Fox to create a new PTV as an anchor section. - HansB

PS - in addition, when trying to click a fox-edit link to a section that does not yet exist, one gets the following foxmessage: Error: cannot find section ''
From looking at the code, it appears that $EditSection is supposed to be in the error message, but apparently it's not making it thru...

Thanks for spotting this bug. Fixed now. - HansB May 11, 2009, at 03:29 AM

so, first:
as suggested I have added:

(:foxptv ptvtarget={$EditTarget} ptvfields={$EditSection} ptvfmt=section :)

however, I noticed one error on the FoxEdit page. in the working examples towards mid-page, the EditSectionForm example:

(:fox editform foxaction=replace put=overwrite target={$EditTarget}{$EditSection}

should instead be:

(:fox editform foxaction=replace put=overwrite target={$EditTarget}#{$EditSection}

then, in FoxEdit, I've found that commenting out the following line causes everything to work as expected, and the new section is added:

   //if ($fts['pos']==0) FoxAbort($pagename,"$[Error: cannot find section] '$section'");

is there a different check that should be made here, instead of commenting it out?
thanks, overtones99 May 13, 2009, at 07:46 PM]]

Hans replied:

I think you are right that the EditSectionForm is missing
a # between {EditTarget} and {EditSection}. That is a bug
needing correction.

But you should not use it anyway as you want to create a new anchor
section as a PTV! I think I will regret forever for having introduced
two totally different type of forms for editing PTVs and for anchor
sections, as it will continue to confuse people.

FoxEdit uses two different ways to call the two different default
edit forms:
For PTVs use the name of the PTV in the markup, like
{[foxedit abc]} to edit PTV 'abc'.
For anchor sections use the anchor name including the # hash
character, like {[foxedit #xyz]} to edit section
But if the abchor section is treated as a PTV, then
use {[foxedit xyz]} to call the PTV edit form.
And to create new PTVs as anchor sections you need to add
ptvfmt=section to the (:fox .... :) markup of the EditPTVForm
(or the relevant custom form if that is what you use).
This also means you do not ned to comment out anything in foxedit.php

If you use markup like {[foxedit #xyz]}, and no [[#xyz]] section is
found, Foxedit aborts with an error message. There is no possibility
to create such a section from the EditSectionForm. This is only
possible if the section is treated as a PTV, and called as a PTV
(without the # hash), and "ptvfmt=section" is added to the form in
the (:fox... markup.

I hope that makes it clearer!


ok, i get it.
i was thinking of PTV's as simply *a thing* on the page, whereas you're thinking of it as an idea - that can include the use of anchored sections. but - it is a little confusing, so i recommend documenting well...

so, it now works without editing the FoxEdit code. here's what i did:
i created a new EditForm for editing sections as if they were PTV's, and I named it EditSectionAsPTVForm - it is exactly the same as the FoxTemplates/EditPTVForm, except for the addition of ptvfmt=section:

(:fox editform ptvtarget={$EditTarget} ptvfields={$EditSection} ptvfmt=section redirect=1:)

i then changed my FoxEdit link so that it calls this new form (no # in front of the section)

{[foxedit myTestSection label="edit testSection2" form=FoxTemplates.EditSectionAsPTVForm]}

that all seems to do the trick. thank you so much for explaining...

now i wonder one last thing. once i've created a section this way and go back to edit it again, as a section, is there any benefit to using the EditSectionForm? it seems using the EditSectionAsPTVForm does this just fine. i guess i'm not sure what difference there really is between these two forms, other than that they probably access two different components of Fox code to do the same thing, right?

thanks again for the help,
overtones99 May 14, 2009, at 02:41 PM]]

Hans' reply to the PmWiki list, 15 May 2009 4:44:50 AM PDT:

Yes, they will do the same thing.
Only they use different components of Fox.
Editing an anchor section is like editing a whole page,
with the difference that only the section is loaded, then updated as
a whole.
Editing a PTV uses Fox's PTV update function, and thesction needs to
be defined as a PTV, which FoxEdit does by default.
So really perhaps we can forget about using the EditSectionForm, and
do everything via PTV editing.
That would be a lot less confusing.

i was thinking of PTV's as simply *a thing* on the page, whereas
you're thinking of it as an idea - that can include the use of
anchored sections. but - it is a little confusing, so i recommend
documenting well...

PmWiki defines various markup as page text variables, and allows
other additional definitions as well. So we have different types of
PTVs. FoxEdit adds anchored sections of format


as a PTV type. Such are not seen as a PTV by default in PmWiki.
When we add or edit PTVs we need to consider which type we want.
The default for Fox are the hidden PTVs of format (:name: value:).
For adding a PTV in another format this nees to be specified with the
ptvfmt= parameter in the (:fox ...:) markup.
For updating a PTV it does not matter what format it is, Fox will use
the same, in fact Fox will just update the content and leave the
format as it is.

But if someone adds a new type of PTV (a new PTV pattern definition in
config.php), then this new format is not automatically available for
Fox's ptvfmt= parameter, because the formats Fox recognises for
adding new PTVs are hard coded. It would need a code change in
fox.php. So Fox will not be able to add such PTVs by setting a value
for the ptvfmt parameter. Still, such different types of PTVs can be
added to a page simply using fox to add content, and specifying it in
the template.


Working Examples of FoxEdit

Q: Hans, could you maybe include a working example for this recipe? A functional example, which I could just copy and paste onto my site, that would be really helpful for me. I don't know if it's that I'm missing something, or if there is some information missing from the recipe page, but I just cannot make this work.

Did you look at FoxContacts? There is a link to a live example on my site. All form pages are in the same group, click the "List Group" button in the footer. And the "source" button can show you the code I used. FoxForum also uses foxedit links. For a very simple example you can take a look here: - HansB January 10, 2008, at 09:04 AM

Thanks very much, Hans - the WikiSandbox2 example on your site cleared up my confusion. I noticed that even though I have $EnablePostDirectives set to "false" in Fox.php, one can still post directives when editing a section. Is there currently any setting I can change to prevent that? - Phil

Thanks! I updated fox.phpΔ so the FoxPTVUpdate function will now also prevent directive posting if $EnablePostDirectives = false. HansB January 12, 2008, at 04:14 AM

Excuse me, but where can I see simple code/source for a working examples of FoxEdit and FoxDelete? Especially I'd like to see it in templates/forms for Fox... Is it possible somewhere?

at present it is implemeted in FoxForum and FoxContacts, both perhaps rather complex examples, as both use display templates as well as form templates.

Here is a basic foxedit example, in wiki source code, to edit a page text variable. The link will call the default Fox form to edit PTVs, which is FoxTemplates.EditPTVForm (source code on FoxEdit page):

VarA: some value

{[foxedit VarA 'edit VarA']}

The next example will open a page section in the default edit form FoxTemplates.EditSectionForm (source code on FoxEdit:

{[foxedit #section1 ]}
text in section1
more text...

The next example will open three PTVs to be edited with a custom Fox form added to Site.FoxTemplates section #customform:

{[foxedit form=Site.FoxTemplates#customform]}\\
(:ptvA: abcdefg:) {$:ptvA}\\
(:ptvB: defghi:) {$:ptvB}\\
(:ptvC: 123456:) {$:ptvC}\\

and the custom form template:

(:fox frm ptvtarget={$EditTarget} redirect=1:)
(:input defaults source={$EditSource} :)
'''Editing {$EditTarget}:'''
|| ptvA||(:input text name=$:ptvA :) ||
|| ptvB||(:input text name=$:ptvB :) ||
|| ptvC||(:input text name=$:ptvC :) ||
|| ||(:input submit post Save:) ||
(:foxend frm:)

Note that FoxEdit defines page variables {$EditTarget} and{$EditSource}, which default to the page or page section being edited. (:input defaults source={$EditSource} :) sayss that the page is used as the source to set default values in the edit form, and the name=$:Var refer to the page's PTVs to be used for the form fields. redirect=1 makes sure the page is reloaded after the PTV update (otherwise you won't see the change immediately, even though the page did change).

Perhaps all this should be on the FoxEdit page. For FoxDelete links I will try to add some examples there. HansB April 03, 2008, at 12:51 PM

Thank you for explanations!

Talk page for the FoxEdit recipe (users?).