Comments

On this page:

Syntax

<txp:comments />

The comments tag can be used as a single tag or a container tag and is used to display the comments associated with a particular article. Comments will be displayed for the present individual article as a default, or to the article set by the id attribute.

Attributes

Tag will accept the following attributes (case-sensitive):

form="form name"
Use specified form template to process each comment.
Default: comments.
limit="integer"
The number of comments to display.
Default: 0 (no limit).
offset="integer"
The number of comments to skip.
Default: 0.
sort="sort value(s)"
How to sort the resulting list.
Values:
discussid (comment ID).
email.
ip (IP address).
message.
name.
parentid (article ID).
posted.
rand() (random).
web.
Default: posted asc.

Common presentational attributes

These attributes, which affect presentation, are shared by many tags. Note that default values can vary among tags.

break="value"
Where value is an HTML element, specified without brackets (e.g. break="li") or some string to separate list items.
Default: li or div, depends upon Preferences administration panel setting for ‘Present comments as a numbered list?’.
class="class name"
HTML class to apply to the wraptag attribute value.
Default: comments (see class cross-reference).
wraptag="element"
HTML element to wrap (markup) list block, specified without brackets (e.g. wraptag="ul").
Default: ol or unset, depends upon Preferences administration panel setting for ‘Present comments as a numbered list?’.

Examples

Example 1: Display comments and give an indication of comments status

<txp:comments />
<txp:if_comments_allowed>
    <txp:comments_form />
<txp:else />
    <p>Comments are turned off for this article.</p>
</txp:if_comments_allowed>

Comments for articles can be turned on or off at the author’s discretion for any article that is published; by using the scheme above in an ‘article’ type form, you can still have the on/off control over comments while still giving users indication of comment status.

Other tags used: comments_form, else, if_comments_allowed.

Example 2: Conditional comments

<txp:if_comments_allowed>
    <txp:comments form="comments" break="li" wraptag="ul" />
    <txp:comments_form />
</txp:if_comments_allowed>

And the comments form (which is a ‘comment’ type form):

<txp:comment_message />
<p class="footnote">
    <a href="mailto:<txp:comment_email />">Email</a> |
    <txp:comment_permlink>
        <txp:comment_id />
    </txp:comment_permlink>
</p>

For the article, list id numbers and a comment input form; but only if comments are currently allowed.

Other tags used: comment_email, comments_form, comment_id, comment_permlink, if_comments_allowed.

Genealogy

Version 4.6.0

Can be used as a container tag.
breakclass attribute deprecated.

See something wrong in this document? Outdated info, a broken link, faulty code example, or whatever? Please write an issue and we’ll fix it.