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.

{count} is overridden while nesting comment module?

March 27, 2012 3:33pm

Subscribe [1]
  • #1 / Mar 27, 2012 3:33pm

    Man With A Peg

    124 posts

    Hey,

    Just wanted to confirm this before I post it as a bug. The exp:comment:entries tag has a {count} variable:

    http://ellislab.com/expressionengine/user-guide/modules/comment/index.html#count

    When I use this code:

    {exp:channel:entries channel="test" sort="desc"}
    Entry {entry_id}:
    
     {exp:comment:entries dynamic="no" entry_id="{entry_id}"}
      {count}
    
     {/exp:comment:entries}
    {/exp:channel:entries}

    the {count} variable is printing out the value for the {exp:channel:entries} tag:

    Entry 2:
    1
    1
    Entry 1:
    2
    2
    2
    2

    This was on 2.2.2 but the same happens on a clean 2.4 site. Any ideas what is going on?

  • #2 / Mar 28, 2012 4:15pm

    Dan Decker

    7338 posts

    Hi Chris,

    It’s not a bug, it stems from the fact that both channel and comment entries tag use the {count} variable. They can’t both exist in harmony, and that is one of the reasons it is noted in the User Guide:

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

    The Comment entries tag should operate outside of the channel entries tag. It will intelligently pull the proper comments for the entry being called.

    {exp:channel:entries channel="test" sort="desc"}
     Entry {entry_id}:
    
    {/exp:channel:entries}
    {exp:comment:entries channel="test"}
     {count}
    
    {/exp:comment:entries}

    I hope this clarifies this for you.

    Let me know if you have any questions!

    Cheers,

  • #3 / Mar 28, 2012 4:51pm

    Man With A Peg

    124 posts

    Alright, thanks Dan. I guess that we will have to use embedded templates for this since we need to show multiple entries + comments on a single page. Everything up to this point has worked great.

    That’s all for today. 😊

  • #4 / Apr 02, 2012 5:17pm

    Dan Decker

    7338 posts

    Hey Chris!

    I’m glad you are pleased with ExpressionEngine!

    If you have other questions in the future, just ask.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases