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 count not working when parent entry is paginated

October 01, 2012 7:30pm

Subscribe [1]
  • #1 / Oct 01, 2012 7:30pm

    gylfisteinn

    41 posts

    Hi,
    I’m having some problems displaying {total_comments}.

    Here is the scenario.

    I have a blog. The comments are displayed both on the frontpage with many blog items and also on the single entry page with one blog item.

    However if I turn on pagination on the frontpage and click on page 2 (see code below) the {total_comments} tag displays nothing on the frontpage, but as usual is fine on the single entry page.

    {exp:channel:entries channel="vikunnar" dynamic="off" limit="5" paginate="bottom"}
    ....
    {exp:comment:entries dynamic="off" channel="vikunnar" entry_id="{entry_id}" limit="1"}{total_comments}{/exp:comment:entries}
    
    {/exp:channel:entries}

    regards,
    Gylfi

  • #2 / Oct 03, 2012 11:27am

    Dan Decker

    7338 posts

    Hi Gylfi,

    I’m sorry for the behavior you are experiencing.

    The explanation is actually outlined in the User Guide:

    NOTE
    The Comment Entries Tag is intended for use in one of your “single entry” pages. That is, a page that shows a single, specific channel entry. Therefore, your Comment page must be linked to from within your Channel entries using the url_title_path variable or the entry_id_path variable, so that the comments can be associated to a specific entry.

    And…

    IMPORTANT
    The Comment Entries tag should not be nested inside of a standard {exp:channel:entries} tag.

    So, 2 things there are: Comments aren’t intended to be used on a multi-entry page, like most typical home pages. And, you shouldn’t nest the tag inside of Channel Entries. In you template, it should be after {/exp:channel:entries}

    Now, what do you want to do exactly? What information do you want to display on the home page and what would you like to have on the internal page?

    Give me the lowdown on what you need to accomplish and I’ll come up with something to help!

    Cheers,

  • #3 / Oct 03, 2012 12:06pm

    gylfisteinn

    41 posts

    Hi,
    I just want to display the total_count of comments for each article on the home page. The home page is displaying the 5 latest blog entries and I want to show how many have commented on the home page (not the comments themselves, I only want those on this single entry page).

    Gylfi

  • #4 / Oct 04, 2012 11:49am

    Dan Decker

    7338 posts

    Sure thing!

    Just use the {comment_total} variable inside you channel entries tag pair:

    {exp:channel:entries channel="vikunnar" dynamic="off" limit="5" paginate="bottom"}
    ....
    {comment_total}
    
    {/exp:channel:entries}

    That should do the trick!

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases