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 alternative statuses if one does not exist

September 10, 2010 2:54pm

Subscribe [2]
  • #1 / Sep 10, 2010 2:54pm

    Clive Portman

    83 posts

    Hi,

    I want to check whether any entries exist with the status ‘Featured’ and, if they exist, display them. But, if there aren’t any, I’d like to revert to displaying entries with the bog standard status ‘Open’.

    I know I could go through all the entries and test the {status} variable, but it seems a bit of a waste to have to go through every entry.

    Is there a more efficient way to do this? Perhaps something like (although I’m sure you can’t run the weblog:entries tage within itself):

    ...og:entries limit=“5” status=“featured”}
    {if no_results}
    ...og:entries limit=“5” status=“open”}
    {/if}

    Thanks, in advance. I’m using 1.6.9.

  • #2 / Sep 10, 2010 5:56pm

    Sue Crocker

    26054 posts

    You could use the query module and do a count of the number of entries that have a status of featured. If the count is zero, then display the exp:weblog:entries tag with status of open or status of featured.

    NOTE: This is meant to just get you started on thinking through the code to do this.

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

ExpressionEngine News!

#eecms, #events, #releases