PDA

View Full Version : Is there a way to display how many comments an article has?


pcoskat
08-11-2008, 07:17 PM
On the index page (and on the article list), I'd sometimes like to list "x comments", rather than 'read more'.

Possible?

northlandadv
08-11-2008, 07:49 PM
Yes. I'm not sure which area you want to put it in, but you'll need to find an article summary type template to insert the code. For example, if the box that's getting pulled into the homepage/default.tpl is summary/default.tpl, this is where you'd put the code (presumably under the article information):

<a href="{article.get_href}"><vte:value select="{LNG_COMMENTS}" /> (<vte:value select="{comment_list_object.get_total_count}" />)</a>

This will give you something that looks like:

Comments (2)

It will link to the article as well.

Micha
08-12-2008, 08:18 AM
Umm, no offense Northland, but have you actually tried that? :)

If you are talking about getting number of comment for article list, this is the proper code to get them:

<vte:value select="{article.get_number_of_comments}" />

You can place it in any of the summary templates, or inside any article list for that matter.

northlandadv
08-12-2008, 01:25 PM
'Course I have! Works great. It's taken directly from box/comments.tpl. Why would you put it in your own template if it didn't work?

northlandadv
08-12-2008, 01:28 PM
But I guess I forgot to post the part about pulling the articleID first :)

Put this prior to the above code:
<vte:params>
<vte:param name="search_article_id" value="{article.get_id}" />
</vte:params>