[pmwiki-users] How to insert at an anchor with FoxEdit's behavior

Hans design5 at softflow.co.uk
Thu Jan 17 06:09:04 CST 2008


Thursday, January 17, 2008, 5:44:17 AM, Randy wrote:

> I want a page that has a link. When the user clicks the link, a form
> to insert a comment appears in place of the page. When the form is  
> submitted, the user is returned to the original page - where the  
> comment now exists.

Try this:
Create a new edit form called for instance FoxTemplates.AddCommentForm
with this content:

(:messages:)
(:fox commentform foxaction=add target={$EditTarget}{$EditSection} redirect=1 :)
(:foxtemplate "{$$text}":)
(:input hidden csum 'comment added':)
|| ||'''Add Comment: {$EditSection}'''||
|| ||(:input textarea id=text name=text value='' cols=70 rows=10 class=inputtext:) ||
(:input hidden access {$Accesscode}:)(:input hidden accesscode {$AccessCode}:) 
|| Author:||(:input text author value='{$Author}' size=30 class=inputtext:) (:input submit post Enter:) ||
(:foxend commentform:)
----
(:include {$EditTarget}{$EditSection}:)


This form is derived from FoxSectionEdit form.
Foxaction is 'add' instead of 'replace'.
And textarea has initial value=''.

Then on your target page insert a foxedit link like

    {[foxedit FoxTemplates.AddCommentForm]}

so foxedit will use your new form.

And as anchor for placing the comments use either
   (:foxprepend commentform:) or (:foxappend commentform:)

Note that AddCommentForm adds the text plainly with
(:foxtemplate "{$$text}":), not formatted in any way.
If it needs to be formatted, put in a div etc. you would need to
create a template page and use that instead.

One could modify the examples of
http://www.pmwiki.org/wiki/Cookbook/FoxCommentBox
to use the comment form and template with the foxedit link.
For instance try the following as FoxTemplates.FoxCommentForm:

(:fox commentform foxaction=add template=FoxTemplates.FoxCommentTemplate target={$EditTarget} redirect=1:)
|| Heading:||(:input text heading size=60:)
|| ||'''Your Message''' ||
|| ||(:input textarea comment cols=60 rows=6:) ||
|| Author:||(:input text author value='{$Author}' :) (:input submit post Enter:) ||
(:foxend commentform:)

(you may want to add captcha code to the form)
and use the template unmodified:

#foxbegin#
(:div1 class=messagehead:)
>>rfloat<<   
[-{$$(date d.m.Y - H:i)}-] &nbsp; (:if auth edit:){[foxdelrange]}(:if:)
>><<
!!!!!{$$author}
(:div1end:) 
>>messageitem<< 
'''{$$heading}'''
>>messageitem<<
{$$comment} 
>><<
#foxend#

So the trick is to specify in the edit form

   target={$EditTarget} redirect=1

in order for {[foxedit FoxTemplates.FoxCommentForm]} to work.


Note that I updated foxedit.php to give an error message in case the
edit form does not exist. Previously the error showed as target page
does not exist, which was confusing.
http://www.pmwiki.org/wiki/Cookbook/FoxEdit


  ~Hans




More information about the pmwiki-users mailing list