Outline:

Info

Latest Version:

1.0 Beta

Created by:

Raymond Irving, July 2005

Function:

Add user comments to documents

Method:

Comments will be stored as a child document of the document currently being viewed.

Notes:

If you are using the NewsListing snippet and are not calling UserComments in the template be sure to wrap it in a chunk so that they can be properly filtered out of NewsListing.

Parameters

  • &displaytpl - display template (chunk name)
  • &formtpl - form template (chunk name)
  • &canpost - comma delimitted web groups that can post comments. Leave blank for public posting
  • &canview - comma delimitted web groups that can view comments. Leave blank for public viewing
  • &badwords - comma delimited list of words not allowed in post
  • &makefolder - set to 1 to automatically convert the parent document to a folder. Defaults to 0
  • &folder - folder id where comments are stored
  • &tagid - a unique id used to identify or tag user comments on a page where multiple comments are required.
  • &freeform - set this option to 1 to use the [+UserComments.Form+] placeholder to relocate the comment form.
  • &postcss - sets the css class used to format the comment block DIV
  • &titlecss - sets the css class used to format the comment title DIV
  • &codecss - sets the css class used to format code tags
  • &numbecss - sets the css class used to format the comment number DIV
  • &authorcss - sets the css class used identify author's comments
  • &ownercss - sets the css class used identify the owner's comments
  • &altrowcss - sets the css class used shade alternate rows
  • &dateformat - sets php date format for new comments (see http://php.net/strftime for formatting options)
  • &sortorder - display the comments oldest first (0) or newest first (1). Defaults to newest first (1)
  • &recentposts - set the number of comments to be displayed. Set to 0 to show all comments. Defaults to 0

Example Call


[[UserComments? &folder=`2`]] Or [!UserComments? &folder=`2`!]
[[UserComments? &folder=`2` &canpost=`RegisteredUsers`]]

Customization

Display total number of comments anywhere on the page:

Use the [+UserComments.Count+] placeholder on the same page as the snippet is called.

Creating a new template:

To create your own templates you will need to have some knowledge of how html works.

Default display template (displaytpl):

[+UID:[+uid+]+]<div[+postclass+]>
<div[+numberclass+]>
[+postnumber+]
</div>
<div[+titleclass+]>
<strong>[+subject+]</strong><span>[+user+] [+createdon+]</span>
</div>
<div class="content">
[+comment+]
</div>
</div>

Default form template (formTpl):

<form method="post" action="[~[id]~]">
<input name="[+tagname+]" type="hidden" value="on" />
Subject:<br /><input name="subject" type="text" size="40" value="" /><br />
Comment:<br /><textarea name="comment" cols="50" rows="8"></textarea><br />
<input name="send" type="submit" value="Submit" />
< /form>

Here the form fields “subject” and “comment” are referred to as [+subject+] and [+comment+] respectively from within the display template.

Add/Remove Fields:

You can add new fields to the form template and reference those fields inside the display template using the [+fieldname+] placeholder format.

For example, let’s say we want to add the email field to our comment form. We would add this inside the template as

<input name=“email” type=“text” size=“30” />

Inside our display template we add the [+email+] placeholder wherever we want the email field to be displayed

Posted by [+email+]

Note: The [+user+], [+createdon+], [+postnumber+], [+UID:[+uid+]+], [+authorclass+] and [+altrowclass+] placeholders are built-in placeholders that the system will replace with the currently logged in user name, the date the comment was posted, the post number, the user id, etc.


( back to top )