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.

Total Entry Count

July 31, 2008 11:30am

Subscribe [4]
  • #1 / Jul 31, 2008 11:30am

    AJP

    311 posts

    Hey all.
    I want to know the total number of entries a certain weblog:entries tag returns, including those across other pages.

    It’s probably a variable I’m missing but I know of these so far.
    {count} - gets me the current iteration of the weblog:entries loop, and is unique to each page of results.
    {total_results} - gets me the total count of entries displayed, per page.
    {absolute_count} - gets me the iteration of this entry, across all pages…

    And then I need a variable to get me the total number of entries found across all pages.
    But either I’m blind, or it doesn’t exist?

    Help?!?

  • #2 / Jul 31, 2008 11:44am

    Mark Bowen

    12637 posts

    For the total number of entries in a certain weblog then you can just use the {total_results} variable in this way :

    {exp:weblog:entries weblog="default_site" disable="member_data|trackbacks|categories|category_fields|pagination"}
    {if count == 1}
    {total_results} entries exist in this weblog
    {/if}
    {/exp:weblog:entries}

    As for across other pages I’m not sure I get what you mean. If you want to know how many are on the page you are on then that would be the same as whatever you have the limit=”“ parameter set to in your weblog tag (if indeed you do have it set).

    The total of all entries in the weblog across other pages would then just be whatever {total_results} is minus whatever you had the limit=”“ parameter set to.

    Hope that helps?


    Best wishes,

    Mark

  • #3 / Jul 31, 2008 11:49am

    Derek Jones

    7561 posts

    So you’re wanting something like an {absolute_results} variable?

  • #4 / Jul 31, 2008 11:53am

    AJP

    311 posts

    Bingo.

    If a weblog:entries tag returned 45 results across 5 pages of 10 results, this value would = 45 every time, on all pages.
    {absolute_count} would change to be the number out of 45 that this entry is (sorted and ordered as specified)
    {total_results} would be 10 on every page (except the last one)
    {count} would be the current index.
    {absolute_results} would be 45 everywhere.

    Thanks!

  • #5 / Jul 31, 2008 12:35pm

    Derek Jones

    7561 posts

    Sounds reasonable enough!

  • #6 / Jul 31, 2008 12:56pm

    Lisa Wess

    20502 posts

    AJP: Did you need the total number of entries across all pages for that weblog entries tag; or just in that weblog?  If the latter, the exp;stats tag should be able to help you.  I just wasn’t sure which you wanted… =)

  • #7 / Jul 31, 2008 12:59pm

    AJP

    311 posts

    For that weblog entries tag, as I’d probably be using the search: parameter, or a category to filter the entries down.

    Thanks for the thought though.

  • #8 / Jul 31, 2008 1:33pm

    SCETV

    15 posts

    I’m on a quest for the same function. I found this plugin, but it seems to provide the wrong count for certain weblogs. And for many of my weblogs, it displays a count of 0.
    http://ellislab.com/forums/viewthread/82484/

    I think the general principle is the same, but I would love to find a way to get an {absolute_count} of the number of entries in a given weblog (and, if possible, even be able to narrow that down to a count of entries in specified categories within that weblog.)

    {absolute_count category="{##|##}”}

  • #9 / Jul 31, 2008 2:49pm

    AJP

    311 posts

    @SCETV: I wouldn’t think you’d need a category parameter, since this variable will exist inside a weblog:entries tag.
    If you need it for a specific category, you’d pass that category as a parameter to the weblog:entries tag (with one, many, not one, or not many).

  • #10 / Jul 31, 2008 2:52pm

    SCETV

    15 posts

    LOL, good point. I did just try the exp:stats and that works well for non-category entry counts. Though strangely, it reports “0” for some of my weblogs. It gets most of them spot on, but a few of them it just spits out “0” - kinda odd.

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

ExpressionEngine News!

#eecms, #events, #releases