ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to display recent comments by category ?

October 08, 2008 5:49am

Subscribe [2]
  • #1 / Oct 08, 2008 5:49am

    flosaurus

    9 posts

    Hi there,

    i’m really new to EE and would like to know how to display the latest comments on each of my weblog’s category.

    currently i have this code :

    <ul class="comments">
    {exp:comment:entries sort="desc" orderby="date" limit="3" dynamic="off" category="5"}
    <li class="clearfix">
    <span class="comment">{comment}</span>
    <span class="user"><strong>{name}</strong> on <a href="http://{comment_url_title_auto_path}">{title}</a></span>
    </li>
    {/exp:comment:entries}
    </ul><!-- comments -->

    But it doesn’t work

    Thank you for your help on this one

  • #2 / Oct 08, 2008 8:57am

    flosaurus

    9 posts

    Ok, while browsing forums for an answer i finaly found what i was looking for !

    {exp:query sql="SELECT wt.title, wt.url_title,c.name,c.comment FROM exp_comments as c
    LEFT JOIN exp_category_posts as cp ON c.entry_id = cp.entry_id
    LEFT JOIN exp_weblog_titles as wt ON cp.entry_id = wt.entry_id
    WHERE cp.cat_id = '4'"}

    {comment} by {name} on {title}

    {/exp:query}

  • #3 / Oct 08, 2008 10:42am

    Robin Sowell

    13255 posts

    Good job of hunting.  You’re correct, the comment tag doesn’t take a category parameter.  In part, because it has to go through the weblog entry to tie into one.  A custom query was the way to go on this one.

    Is it working solid for you using that approach?  (And thanks for sharing the code snippet!)

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases