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.

comment_total AND total_comments returning 0

February 18, 2012 9:55am

Subscribe [3]
  • #1 / Feb 18, 2012 9:55am

    Sobral

    87 posts

    This question may be related to a resolved thread.

    Dear boss,

    I tried {if '{count}’ == ‘{total_comments}’} and {if count == total_comments} conditionals, but just doesn’t work. So I tested {total_comments} variable and got a 0.

    The comments tag are outside channel:entries tag. And even inside channel:entries tag, the {comment_total} tag returns 0.

    At the table exp_channel_titles of database, all rows of the comment_total column is 0! Weiiiiiiiiird!

    Is there a query I can execute to fix this?

    Thanks for you attention!

  • #2 / Feb 18, 2012 11:40am

    Sobral

    87 posts

    This queries fixed {comment_total}, but doesn’t fixed {total_comments}:

    UPDATE exp_channel_titles AS a SET recent_comment_date = (SELECT MAX(comment_date) FROM exp_comments AS me WHERE me.entry_id = a.entry_id), comment_total = COALESCE((SELECT COUNT(1) FROM exp_comments AS me WHERE me.entry_id = a.entry_id),0)
    
    UPDATE exp_members AS a SET last_comment_date = (SELECT MAX(comment_date) FROM exp_comments AS me WHERE me.author_id = a.member_id), total_comments = COALESCE((SELECT COUNT(1) FROM exp_comments AS me WHERE me.author_id = a.member_id),0)
  • #3 / Feb 19, 2012 8:02am

    Sean C. Smith

    3818 posts

    Hi Robson Sobral,

    Sorry you are having this trouble. I just want to clarify that your {comment_total} and {total_comments} variables are showing no value but there are actually comments in the system. Is this correct?

    If this is the case I suggest you go to Tools > Data > Recount Statistics and perform a recount.

    Let me know if this resolves the problem for you?

    Sean

  • #4 / Feb 19, 2012 9:41am

    Sobral

    87 posts

    Hi, Sean! Dude, its Sunday! What are you doing here?

    Sadly, recount statistics didn’t fix the problem. {comment_total} is working fine after I do the queries I mentioned before, but {total_comments} doesn’t.

    I was looking at mod.comment.php and found those lines:

    $row['total_comments'] = $pagination->total_rows;
    if ($pagination->paginate === TRUE)
    {
     // When we are only showing comments and it is 
     // not based on an entry id or url title
     // in the URL, we can make the query much 
     // more efficient and save some work.
     $pagination->total_rows = $this->EE->db->count_all_results();
    }

    Looks like {total_comments} is just defined if the pagination is enabled. So, I made some tests with paginate parameter and pagination tags. If I add these lines to the comment:entries tag, {total_comments} works:

    {paginate}{pagination_links}{/paginate}

    The paginate or even the limit parameters aren’t needed. I believe that in case pagination === FALSE and without limit parameter, {total_comments} should be equal to {total_results}.

    Should I open a bug report?

    Thank you for your attention, Sean!

  • #5 / Feb 23, 2012 5:27pm

    Kevin Smith

    4784 posts

    I’m not sure it’s actually a bug, Robson, but I want you to open the bug report with your explanation so that the devs can have a look and decide. I know that outside the comments tag, the total_comments variable actually returns the total number of comments made by the logged-in user. There may be something mixed up in the system, and I’d love the devs to have a look.

  • #6 / Feb 27, 2012 8:52pm

    Sobral

    87 posts

    Bug reported! Thanks, Kevin and Sean!

  • #7 / Feb 28, 2012 3:08pm

    Shane Eckert

    7174 posts

    Hello Robson,

    Thank you! Stay tuned into the bug for what comes next.

    Is there anything else I can help you with? Hopefully this gets sorted soon. 😊

    Cheers,

  • #8 / Feb 28, 2012 3:21pm

    Sobral

    87 posts

    Thanks, Shane. You can close the thread.

  • #9 / Feb 29, 2012 1:52pm

    Shane Eckert

    7174 posts

    Hello Robson,

    Great! Thanks again for filing the bug!

    Cheers,
    Shane

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

ExpressionEngine News!

#eecms, #events, #releases