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 comes up as zero

May 21, 2012 9:24pm

Subscribe [2]
  • #1 / May 21, 2012 9:24pm

    Adam Christianson

    115 posts

    This question may be related to a resolved thread.

    I’m having almost the exact same issue as mention in this thread, but in my case even calling {total_comments} from inside the channel:entries results in a zero. Yet, I can successfully return all the comments using the following:

    {exp:comment:entries sort="asc" orderby="date" limit="25" paginate="bottom"}
         {if count == 1}<span class="red">{total_comments}</span> Comments <span class="right sub-title"><a href="#">Leave Your Own</a></span>{/if}
         {comment}
    {/exp:comment:entries}

    With the above code I get a total count of ‘0’

    If I try just:

    {exp:comment:entries}
    {total_comments}
    {/exp:comment:entries}

    The result is:
    0 0

     

  • #2 / May 22, 2012 5:41pm

    Dan Decker

    7338 posts

    Hi Adam Christianson,

    It looks like you might have run into this bug. Can you apply the fix and let me know the result?

    Cheers,

  • #3 / May 22, 2012 6:40pm

    Adam Christianson

    115 posts

    Is it fixed in 2.5, should I just update? I’m in 2.4 in a dev environment at the moment.

  • #4 / May 22, 2012 6:59pm

    Adam Christianson

    115 posts

    Actually following those instruction yielded this error:

    A PHP Error was encountered
    Severity: Notice
    Message: Undefined variable: total_rows
    Filename: comment/mod.comment.php
    Line Number: 444

    Obviously the reason is that $total_rows is never defined. Not sure the bug fix is correct. In my mod.comment.php file on at line 442 I had this code:

    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();
      }

    So I replaced it with this code and it seems to work for me.

    $pagination->total_rows = $this->EE->db->count_all_results();

    My mod.comment.php file is labeled as:

    /**
     * ExpressionEngine - by EllisLab
     *
     * @package  ExpressionEngine
     * @author  ExpressionEngine Dev Team
     * @copyright Copyright (c) 2003 - 2012, EllisLab, Inc.
     * @license  <a href="http://ellislab.com/expressionengine/user-guide/license.html">http://ellislab.com/expressionengine/user-guide/license.html</a>
     * @link  <a href="http://expressionengine.com">http://expressionengine.com</a>
     * @since  Version 2.0
     * @filesource
     */

    This should be an out of the box 2.4.0 install, so did I somehow maybe get the wrong build?

  • #5 / May 30, 2012 3:42pm

    Dan Decker

    7338 posts

    Hi Adam,

    Indeed, according to the 2.5 Change Log, this bug fix was included.

    This should be an out of the box 2.4.0 install, so did I somehow maybe get the wrong build?

    We don’t do builds of ExpressionEngine anymore, but the number is still included for legacy purposes. Now, when EE is updated in anyway, a version number will increase.

    Bug fixes and security enhancement increment the 3rd number - 2.5.1
    Feature releases increment the 2nd number - 2.6

    In this scheme, the build number represents the date the version was initially available.

    More to the point, it looks like the bug report is confusing regarding the fix and what you have done is working for you, correct?

    Cheers,

  • #6 / May 30, 2012 11:44pm

    Adam Christianson

    115 posts

    Thanks. Yup, my fix is working for me at the moment, but now that 2.5.1 is here I should probably just update to that. 😉

  • #7 / Jun 01, 2012 2:16pm

    Shane Eckert

    7174 posts

    Hey Adam Christianson,

    Glad to hear it! Dan is pretty awesome.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases