Table of Contents

txp:comments

The comments tag is a Single Tag. Textpattern will replace this tag with 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.

Syntax

The comments tag has the following syntactic structure…

<txp:comments />

Attributes

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

id="article ID#"

The article you want to view comments for. Default is current article. Attribute works only on non-individual article pages.

sort="sort value(s)"

How to sort the resulting list. Available values: discussid (comment ID#), parentid (article ID#), name, email, web, ip IP address, posted, message, rand() random. Default is posted asc.

form="form name"

Default is comments.

wraptag="tag"

(X)HTML tag (without brackets) to wrap around list. Default depends upon Present Comments as a Numbered List? preference setting, either ol or unset.

break="value"

(X)HTML tag (without brackets) or string used to separate comments. Default depends upon Present Comments as a Numbered List? preference setting, either li or div.

class="class name"

(X)HTML class attribute to be applied to wraptag. Default is comments.

breakclass="class name"

(X)HTML class attribute to be applied to break (when value supplied is a tag). Default is unset.

Examples

Display comments, and give user's an indication of "Comments" status.

Comments for articles can be turned off or on at the authors discretion for any article that is published; by using the following scheme in an article form, you can still have the on/off control over comments while still giving users indication of comment 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>

Other tags used: <comments_form />, <if_comments_allowed>

Column list for displaying id numbers for comments for article id 3, and a comment input form, if comments are currently allowed on article id 3.

Tags

<txp:if_comments_allowed id="3">
	<txp:comments id="3" form="lineitem" breakclass="special" break="li" wraptag="ul" />
 
	<txp:comments_form id="3" />
</txp:if_comments_allowed>

Form (lineitem) Type(comment)

<small><txp:comment_id /></small>

Styles could go this way

.special
{
        display:list-item;
        list-style-type:none;
}

Other tags used: <comment_id />, <comments_form />, <if_comments_allowed>