quick question about {total_results} variable

December 07, 2012 12:40am

Subscribe [3]
  • #1 / Dec 07, 2012 12:40am

    manuqc's avatar


    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

  • #2 / Dec 08, 2012 4:07pm

    Gareth Davies's avatar

    Gareth Davies

    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'"}
  • #3 / Jan 01, 2013 6:41pm

    manuqc's avatar


    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!


  • #4 / Mar 05, 2013 7:20pm

    Ralph123's avatar


    25 posts


    I tried using total_results and 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

ExpressionEngine News

#eecms, #events, #releases