EllisLab text mark
Advanced Search
quick question about {total_results} variable
Posted: 07 December 2012 12:40 AM
Joined: 2008-07-31
115 posts


I am trying to create a menu that has school program names with a little parenthesis next to each one showing how many sub-programs are assigned to the main program.

Problem being that I am getting the program name repeated the number of times there are weblog entries for.

I just want to use the “{total_results}” to show the total but no to show any other content. If I use that it shows the total, but also repeats it as I ve said before.

This is my current code:

{exp:channel:entries channel="microsoft" dynamic="off" disable="categories|trackbacks|member_data|pagination"} ({total_results})*</div> {/exp:channel:entries}

Also, I if I use, limit=”1” I do not get the total number of entries, as it assumes its one only…

thanks for your time


el pobre no es el que tiene poco sino el que desea más…

Posted: 08 December 2012 04:07 PM   [ # 1 ]
Joined: 2008-08-23
488 posts


A few ways of doing this, using your existing code the simplest way would just be to show the total results only on the first result so:

{exp:channel:entries channel=“microsoft” dynamic=“off” disable=“categories|trackbacks|member_data|pagination”}
{if count=="1"}<span>({total_results})<sup>*</sup></span>{/if}

A better way of doing it would be to use the query module replacing channel_id number (e.g. 1 below) with the id number of the ‘microsoft’ channel

{exp:query sql="SELECT Count(exp_channel_titles.channel_id) AS total_results FROM exp_channel_titles WHERE exp_channel_titles.channel_id = '1'"}
Posted: 01 January 2013 06:41 PM   [ # 2 ]
Joined: 2008-07-31
115 posts

Hi Gareth,

I do apologize for the huge delay..

I wanted to thank you for taking the time on this, I just jumped onto some stuff and forgot to reply… the query code you posted did it for me!!! thanks again for your time!



el pobre no es el que tiene poco sino el que desea más…

Posted: 05 March 2013 07:20 PM   [ # 3 ]
Joined: 2012-04-15
25 posts


I tried using total_results and absolute_total_results (http://devot-ee.com/add-ons/absolute-total-results) in the below

{exp:channel:entries channel="gcse" dynamic="off"}
{if member_list == "{segment_2}" }
{if count=="1"}<span>({total_results})<sup>*</sup></span>{/if}


but the conditional screws with the result calculation

with the conditional there are 2 results and using (count) proves that as does the output total_results and absolute_total_results returns 19 which is the result without the conditional i.e. there are 19 entries in the channel called

Any ideas why total_results and absolute_total_results ignore the conditional

Any fix? Thanks