0

If have a channel called 'scripts' and i want to display how many entries are in the channel filtered by the categorie they are in. For the category id 5 it should returns 4 entries. But it is displayed like 4 4 4 4. How can show the {absolute_results} only once?

{exp:channel:entries channel="scripts" category="5" disable="category_fields"}
    {absolute_results}
{/exp:channel:entries}

Update (full code):

{exp:channel:categories channel="scripts" style="linear"}
    {exp:channel:entries channel="scripts" category="{category_id}" disable="category_fields"}
        {if absolute_results == absolute_results}
            <strong>{absolute_results}</strong>
        {/if}
    {/exp:channel:entries}
{/exp:channel:categories}
0

The channel entries loop run 4 times so you get repeated values.

Try something like this:

{exp:channel:entries
    channel="scripts" dynamic="no" category="5"
    disable="custom_fields|categories|category_fields|member_data|pagination|trackbacks|relationships"
}
    {if count == total_results}
        {total_results}
    {/if}
{/exp:channel:entries}

Update based on question update involving categories tag pair:

You should go with query:

{exp:query sql="SELECT COUNT(ct.entry_id) as ab_results FROM exp_channel_titles ct JOIN exp_category_posts cp ON cp.entry_id = ct.entry_id WHERE ct.channel_id=29 AND cp.cat_id=65"}
    {ab_results} 
{/exp:query}

Query module is required to run this.

| improve this answer | |
  • That works, but I want to do this without the count because i'm setting the category_id dynamically. Im using the categories tag with the entries tag like this so my count is not equal to the absolute_results: <br/>{exp:channel:categories channel="scripts" style="linear"} {exp:channel:entries channel="scripts" category="{category_id}" disable="category_fields"} {if absolute_results == absolute_results} <strong>{absolute_results}</strong> {/if}<br/> {/exp:channel:entries} {/exp:channel:categories} – Dave_Daliz Aug 30 '16 at 9:27
  • Well in that case, Channel entries tag won't help you. You should go with query. {exp:query sql="SELECT COUNT(ct.entry_id) as ab_results FROM exp_channel_titles ct JOIN exp_category_posts cp ON cp.entry_id = ct.entry_id WHERE ct.channel_id=29 AND cp.cat_id=65"} {ab_results} {/exp:query} Query module required to run this. – Mufi - Amici Infotech Aug 30 '16 at 10:16
0

I resolved it by using an Add-on called Construct Categories by Buzzingpixel.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.