|
Cookbook /
FoxCommentBoxSummary: Adding a comment form using Fox
Version: 2006-04-03a
Prerequisites: PmWiki 2.2.0
Status:
Maintainer: HansB
Questions answered by this recipeHow can I add a comment form to a page, so users can add comments (even though they may not be logged on)? DescriptionYou can add a comment form (commentbox) using Fox. Comments can be placed on the same page or a different target page, and appended or prepended relative to the top or bottom of the page or a marker in a special location. Appended comments appear in chronological order (last below previous), prepended comments in reverse chronological order (last on top). The following is an example for a commentbox markup. The comment box uses a template page, with its markup shown later. Commnets are placed below a heading of Site.FoxCommentBox
(:fox cbox put=below mark=!!Comments template=Site.FoxCommentTemplate:)
|| 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 cbox:)
If you need Captcha or AccessCode enabled (for wikis which allow any visitor to post a comment), set Site.FoxCommentBox with Captcha or Access Code
(:fox cbox put=below mark=!!Comments template=Site.FoxCommentTemplate:)
(:input hidden accesscode {$AccessCode}:)
|| Heading:||(:input text heading size=60:)
|| ||'''Your Message''' ||
|| ||(:input textarea comment cols=60 rows=6:) ||
(:if enabled EnableAccessCode:)
|| ||Enter value {$AccessCode} (:input text access size=3 class=inputtext:)
(:input hidden accesscode {$AccessCode}:) <- Have you entered the code number?||
(:if enabled EnablePostCaptchaRequired:)
|| ||Enter value {$Captcha} (:input captcha class=inputtext:) <- Have you entered the code number?||
(:if:)
|| Author:||(:input text author value='{$Author}' :) (:input submit post Enter:) ||
(:foxend cbox:)
Both examples can be varied in many ways, both in layout and in function.
Note that the options put=aboveform and put=belowform only work if the form is part of the page, and not included with an
To post to a PageName-Comments page, use:
Include the comments on PageName-Comments in the current page, and the CommentForm with:
Site.FoxCommentTemplate
#foxbegin#
(:div1 class=messagehead:)
>>rfloat<<
[-{$$(date d.m.Y - H:i)}-] (:if auth edit:){[foxdelrange]}(:if:)
>><<
!!!!!{$$author}
(:div1end:)
>>messageitem<<
'''{$$heading}'''
>>messageitem<<
{$$comment}
>><<
#foxend#
This template gives a formatting to each comment post. It also adds a post delete button, for 'edit' authorised users. In any case these are just simple examples, lots of different comment forms can be built. For general use put the FoxCommentBox and FoxCommentTemplate into the Site group (or change the template= parameter to suit your location). Then you can add a commentbox in any page with (:include Site.FoxCommentBox:)
Posting permissionsBy default Fox allows posting by any user who got edit permission to the (target) page. If you need users to post to a read-protected (private) page, you need to set NotesRelease Notes
CommentsBecause if lost 6 hours of few little problems, I post my solution here : Page with form
(:if ! exists {*$FullName}-Comments:)No comments for the moment(:if:)
(:include {*$FullName}-Comments :)
(:fox formComment:)
(:if ! exists {*$FullName}-Comments:)
(:foxadd Site.FoxTemplate-FirstComment=>{*$FullName}-Comments :)
(:if exists {*$FullName}-Comments:)
(:foxadd Site.FoxTemplate-Comment=>{*$FullName}-Comments :)
(:if:)
(:foxcheck comment msg='You must post a comment' :)
(:foxcheck author msg='You must post an author' :)
(:foxmessage formComment comment :)\\
(:foxmessage formComment author :)\\
(:input textarea comment rows=3 cols=60:)\\
Author : (:input text author value='{$Author}' size=30 :)\\
Enter value {$Captcha} (:input captcha:) <- Captcha\\
(:input submit post value='Post':)
(:foxend formComment:)
Page Site.FoxTemplate-Comment
#foxbegin#
(:div1 class=messagehead:)
>>rfloat<<
[-{$$(date d.m.Y - H:i)}-]
>><<
!!!!!{$$author}
(:div1end:)
>>messageitem<<
{$$comment}
>><<
#foxend#
Page Site.FoxTemplate-FirstComment
!Comments (directive foxprepend must have a text before !!)
(:foxprepend formComment:) (warning : no space before the name of the form)
#foxbegin#
(:div1 class=messagehead:)
>>rfloat<<
[-{$$(date d.m.Y - H:i)}-]
>><<
!!!!!{$$author}
(:div1end:)
>>messageitem<<
{$$comment}
>><<
#foxend#
This is perhaps a misunderstanding. The first word in the See AlsoContributors
User notes?: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date * (-) Optional negative comment. Name, date These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |