Current Setup
- I have 5 entries in the "internal_ads" channel that rotate on the homepage.
- I have set up a category of "urgent" that has 1 entry in it.
- I'm using stash to set a list of adverts, then running through the list in my template to get them to rotate.
What I want to happen
When an entry is added to the urgent
category, I want that entry to be the only ad to display.
What I've tried
I currently have the following in my initial template that sets the stash list and works correctly for getting the 5 ads.
{stash:embed:layouts:homepage}
{!-- Set data for Internal Adverts --}
{exp:stash:set_list name="internal_ads" parse_tags="yes" parse_depth="2"}
{exp:channel:entries channel="internal_adverts" dynamic="no" orderby="random" limit="1"}
{stash:url_title}{url_title}{/stash:url_title}
{stash:advert_title}{title}{/stash:advert_title}
{stash:short_description}{short_description}{/stash:short_description}
{stash:homepage_image}{homepage_image}{/stash:homepage_image}
{/exp:channel:entries}
{/exp:stash:set_list}
I have tried the following using conditionals to try checking if there's an entry in the urgent
category and if there isn't then set the list as before. If there is, then only use that entry. It doesn't want to work and I can't really see why.
{stash:embed:layouts:homepage}
{!-- Set data for Internal Adverts --}
{exp:stash:set_list name="internal_ads" parse_tags="yes" parse_depth="2"}
{exp:channel:entries channel="internal_adverts" dynamic="no" orderby="random" limit="1" category="36"}
{if no_results}
{/exp:channel:entries}
{exp:channel:entries channel="internal_adverts" dynamic="no" orderby="random" limit="1"}
{stash:url_title}{url_title}{/stash:url_title}
{stash:advert_title}{title}{/stash:advert_title}
{stash:short_description}{short_description}{/stash:short_description}
{stash:homepage_image}{homepage_image}{/stash:homepage_image}
{/exp:channel:entries}
{if:else}
{stash:url_title}{url_title}{/stash:url_title}
{stash:advert_title}{title}{/stash:advert_title}
{stash:short_description}{short_description}{/stash:short_description}
{stash:homepage_image}{homepage_image}{/stash:homepage_image}
{/if}
{/exp:channel:entries}
{/exp:stash:set_list}
Any help is greatly appreciated.