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.

Can't get category count within entries tag

December 19, 2009 7:27pm

Subscribe [1]
  • #1 / Dec 19, 2009 7:27pm

    draymond

    22 posts

    I can’t seem to get the category count when inside the entries tag. With first attempt, count resolves to the count for entries, so it’s only “1” for the first entry:

    {exp:weblog:entries weblog="{my_weblog}"}
    <h1>{title}</h1>
    
    {categories backspace="1"}
    {if {count} == "1"}
    in {/if}<a href="http://{path=site_index}">{category_name}</a>,
    {/categories}
    
    {body}
    {/exp:weblog:entries}

    With second attempt, EE’s parsing order does not allow assign_variable to happen throughout the loop, so catcount is always “1”:

    {exp:weblog:entries weblog="{my_weblog}"}
    <h1>{title}</h1>
    
    {assign_variable:catcount="1"}
    {categories backspace="1"}
    {if {catcount} == "1"}
    in {/if}<a href="http://{path=site_index}">{category_name}</a>,
    {assign_variable:catcount="2"}
    {/categories}
    
    {body}
    {/exp:weblog:entries}

    Is there a way to do this? Thanks!

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

ExpressionEngine News!

#eecms, #events, #releases