dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Search | Go
Wiki > System > Plugins > CommentPlugin > CommentPluginTemplate

Templates for CommentPlugin

See CommentPlugin: Customisation for help.

While this topic can be viewed as a topic, it is used by the CommentPlugin as a template file. The syntax is the same as used for the templates used for presentation in skins - see SkinTemplates. The important content in here is in the verbatim blocks. The rest of the topic is just comments.

hand See CommentPluginExamples to view rendered templates


Put your local templates into UserCommentsTemplate? (create if it does not exist yet). Local templates defined in that topic will override templates defined below.

Template definitions

ALERT! Note that the use of URLPARAM in the templates should be done in a way that prevents Cross Site Scripting attacks. The safest is to let URLPARAM encode the unsafe characters (default) but this prevents the user from entering Foswiki macros in the comment input fields. It is however safe to use encode="off" when the following rules are observed.
  • The encode="off" option for URLPARAM is only used in this topic within verbatim tags to prevent this topic from being an XSS attack vector.
  • The encode="off" option is only used in OUTPUT defs and never in the PROMPT.

Templates used in rest of file

Generic prompt box used by other templates
%TMPL:DEF{promptbox}%<div class="commentPlugin commentPluginPromptBox"><table border="0" cellpadding="0" cellspacing="0"><tr valign="middle"><td><textarea %DISABLED% rows="%rows|3%" cols="%cols|70%" name="comment" class="foswikiInputField" onfocus="if(this.value=='%MESSAGE%')this.value=''" onblur="if(this.value=='')this.value='%MESSAGE%'">%MESSAGE%</textarea></td><td>&nbsp;<input %DISABLED% type="submit" value="%button|Add comment%" class="foswikiButton" /></td></tr></table></div><!--/commentPlugin-->%TMPL:END%
Short comment, signed and dated
%TMPL:DEF{outputoneliner}%   * %URLPARAM{"comment" encode="off"}% -- %WIKIUSERNAME% - %GMTIME{"$day $month $year"}%%TMPL:END%

hand See rendered template Default

User templates


Comments, signed and dated, added at top of file


hand See rendered template top


Comments, signed and dated, added at end of file

hand See rendered template bottom


Comments, signed and dated, added immediately before anchor

hand See rendered template above


Bullet item added immediately before anchor. The input field width is passed with parameter inputsize, for example:
%COMMENT{type="bulletabove" inputsize="20"}%

%TMPL:DEF{PROMPT:bulletabove}%<input class="foswikiInputField" name="bullet_above_item" id="bullet_above_item" type="text" size="%inputsize|40%" value="%URLPARAM{"bullet_above_item"}%" />&nbsp;<input %DISABLED% type="submit" value="%button|Add item%" class="foswikiButton" />%TMPL:END%
%TMPL:DEF{OUTPUT:bulletabove}%   * %URLPARAM{"bullet_above_item" encode="off"}%%POS:BEFORE%

hand See rendered template bulletabove


Wiki thread mode comment, signed and dated

%URLPARAM{"comment" encode="off"}%


hand See rendered template threadmode


Comments, signed and dated, added recurse after comment box.


%URLPARAM{"comment" encode="off"}%


hand See rendered template belowthreadmode


Comments, signed and dated, added immediately below anchor

hand See rendered template below


Comments, signed and dated, added at top of table below the anchor/location/COMMENT
%TMPL:DEF{OUTPUT:tableprepend}%%POS:AFTER%| %URLPARAM{"comment" newline="<br />" encode="off"}% | %WIKIUSERNAME% | %SERVERTIME% |

hand See rendered template tableprepend


Comments, signed and dated, added at end of table above the anchor/location/COMMENT
%TMPL:DEF{OUTPUT:tableappend}%%POS:BEFORE%| %URLPARAM{"comment" newline="<br />" encode="off"}% | %WIKIUSERNAME% | %SERVERTIME% |

hand See rendered template tableappend

after: Add before the comment box, after the last comment


hand See rendered template after


Action added to action table directly above comment box (requires Foswiki:Extensions/ActionTrackerPlugin)

%TABLE{databg="#ffffff" tableborder="0" cellborder="0"}%
|        <label for="action_who">Action for</label>| <input class="foswikiInputField" name="action_who" id="action_who" type="text" size="50" value="%URLPARAM{"who"}%" /> |
| <label for="action_due">Due date</label>| <input class="foswikiInputField" name="action_due" id="action_due" type="text" size="30" value="%URLPARAM{"due"}%" /> |
|    <label for="action_comment">Comment</label>| <textarea %DISABLED% rows="%rows|3%" cols="%cols|50%" name="action_comment" id="action_comment" class="foswikiInputField" onfocus="if(this.value=='%MESSAGE%')this.value=''" onblur="if(this.value=='')this.value='%MESSAGE%'">%MESSAGE%</textarea> |
|| <input %DISABLED% type="submit" class="foswikiButton" value="Add action" /> |
%TMPL:DEF{OUTPUT:action}%%POS:BEFORE%%AC%NOP%TION{who="%URLPARAM{"action_who" encode="off"}%" due="%URLPARAM{"action_due" encode="off"}%"}% %URLPARAM{"action_comment" encode="off"}%<br />- Created by %WIKIUSERNAME%, %SERVERTIME%%ENDACTION%

hand See rendered template action


Tablerows adding on end
%TABLE{databg="#ffffff" tableborder="0" cellborder="0"}%
|        <label for="comment_date">Date</label>| <input class="foswikiInputField" %DISABLED% type="text" size="40" name="comment_date" id="comment_date" /> |
|        <label for="comment_city">City</label>| <input class="foswikiInputField" %DISABLED% type="text" size="40" name="comment_city" id="comment_city" value="" /> |
|| <input %DISABLED% type="submit" class="foswikiButton" value="%button|Add entry%" /> |
%TMPL:DEF{OUTPUT:table}%%POS:BEFORE%| %URLPARAM{"comment_date" encode="off"}% | %WIKIUSERNAME% | %URLPARAM{"comment_city" encode="off"}% |

hand See rendered template table


Talk using TOC adding on end
%TABLE{databg="#ffffff" tableborder="0" cellborder="0"}%
|        <label for="comment_summary">Summary</label>| <input class="foswikiInputField" %DISABLED% type="text" size="40" name="comment_summary" id="comment_summary" /> |
|        <label for="toctalk_comment_text">Message</label>| <textarea %DISABLED% rows="%rows|3%" cols="%cols|50%" name="toctalk_comment_text" id="toctalk_comment_text" class="foswikiInputField" onfocus="if(this.value=='%MESSAGE%')this.value=''" onblur="if(this.value=='')this.value='%MESSAGE%'">%MESSAGE%</textarea> |
|| <input %DISABLED% type="submit" value="%button|Add%" class="foswikiButton" /> |
%POS:BEFORE%---++++ %SERVERTIME% %WIKIUSERNAME%: %URLPARAM{"comment_summary" encode="off"}%
%POS:BEFORE%%URLPARAM{"toctalk_comment_text" encode="off"}%

hand See rendered template toctalk


Create a list of annotated bookmarks
%TABLE{databg="#ffffff" tableborder="0" cellborder="0"}%
|        <label for="comment_url">Url</label>| <input class="foswikiInputField" %DISABLED% type="text" size="40" name="comment_url" id="comment_url" value="http://" /> |
| <label for="comment_link">Link label</label>| <input class="foswikiInputField" %DISABLED% type="text" size="40" name="comment_link" id="comment_link" /> |
|    <label for="bookmark_comment_text">Comment</label>| <input class="foswikiInputField" %DISABLED% type="text" size="40" name="bookmark_comment_text" id="bookmark_comment_text" value="%MESSAGE%" /> |
|| <input %DISABLED% type="submit" value="%button|Add bookmark%" class="foswikiButton" /> |
%TMPL:DEF{OUTPUT:bookmark}%%POS:BEFORE%   * [[%URLPARAM{"comment_url" encode="entity"}%][%URLPARAM{"comment_link" encode="entity"}%]] %IF{" '%URLPARAM{"bookmark_comment_text" encode="entity"}%' = '' " then="" else="- "}%%URLPARAM{"bookmark_comment_text" encode="entity"}%

hand See rendered template bookmark


Post to a different topic and return to here. The comment target is set in the PROMPT. In the form below the redirectto is set to the current (including) topic.

<input type="hidden" name="redirectto" value="%BASEWEB%.%BASETOPIC%" />

hand See rendered template return

Include UserComments

Including UserCommentsTemplate? ("Template" gets automatically appended to the name):

r1 - 15 Jan 2011 - 22:11:21 - ProjectContributor
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback