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.

Show something based on number of entries

July 05, 2012 3:56am

Subscribe [3]
  • #1 / Jul 05, 2012 3:56am

    Heiko

    135 posts

    Hi there,

    I’ve built a filter module that only needs to be shown, when the current number of entries equals 10 or more. So, I tried the following:

    {if count >= "10"}
    filter_module
    {/if}

    It works, but the filter module is looped as well, which I don’t prefer! 😉

    Can somebody please help?

    Thanks.

  • #2 / Jul 05, 2012 4:03pm

    Shane Eckert

    7174 posts

    Hey Heiko,

    Thank you for posting your question here on the ExpressionEngine forums.

    What do you mean the filter module is looped as well? If the conditional is met, the results just just be included. Is this in an embed or straight in a template? Can you show me some of the surrounding code?

    One more question. Is it the conditional that you believe is not working or the module you wrote?

    Thank you,

  • #3 / Jul 06, 2012 12:51am

    Heiko

    135 posts

    Hi there,

    it seems I got the whole idea behind {count} wrong, which in itself is great, but not what I currently need.

    I don’t want to modify an entry based on it’s number, I want to conditionally embed a snippet, when the post-count of the current channel equals 10 or more.

    Something like this:

    {exp:channel:entries channel="{embed:channel}" orderby="date" sort="desc" dynamic="no"}
    
    {if number_of_entries >= "10"}
      {snp_filter}
    {/if}
    
    {/exp:channel:entries}

    The problem - besides the fantasy variable - is, that when I do it like this, the snippet is repeated for every entry in the loop.

    So basically I just want to show some HTML anywhere on the page based on the number of entries currently displayed on that page.

    Thanks! 😊

  • #4 / Jul 06, 2012 12:28pm

    Kurt Deutscher

    827 posts

    My first thought is:

    {if count == '11'}
    Do something once
    {/if}

    And then set the limit=“11” paramater in the channel tag.

    My second thought is that (since the snippet it loaded on every template; even when it’s not used) that you may want to consider an embedded template instead, especially if most pages won’t need the snippet.

  • #5 / Jul 06, 2012 2:10pm

    Heiko

    135 posts

    Well, thanks for your help, but I need the snippet to show in dependency of the number of entries not on a separate template.

    Unfortunately the {count}-method doesn’t work, because my snippet is repeated when I have to put it inside the loop.

    Maybe it’s possible to store the post count into a php-variable and then set the conditional outside of the EE-tags?

  • #6 / Jul 06, 2012 4:15pm

    Shane Eckert

    7174 posts

    Hey Heiko,

    That sounds like an option. If you want I can move this thread to the Community Help Forum. You might also want to check out stash.

    This is probably not useful here, but you may wish to note Switchee for reference.

    Cheers,

  • #7 / Jul 07, 2012 1:28am

    Heiko

    135 posts

    Thanks for the links, Shane. And no problem with moving this thread.

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

ExpressionEngine News!

#eecms, #events, #releases