This one kept me busy for a while and I although could find similar questions none of the solutions worked.
Using template partials, gather the page content then send though (via embed) to a master wrapper template. This site has 'pages' where the URL should identify a unique entry, but EE tries it's best to show something, adding require_entry
in the Channel tag should trigger no_results
if an entry can't be found.
{no_results}
works as expected when trying the channel:entries
tag (below) outside of stash. Looking at stash docs, unprefix
is specifically for this scenario. The below code does work.
{exp:stash:set
name = "st_page_content"
parse_tags = "yes"
unprefix = "my_prefix"
}
{exp:channel:entries
channel = "channel_short_name"
limit = "1"
require_entry = "yes"
}
<p>{title}</p>
{if my_prefix:no_results}<p>no results</p>{/if}
{/exp:channel:entries}
{/exp:stash:set}
But it doesn't work when stashing multiple variables between 1 stash tag pair. Eg. no_results
is not stored in st_page_content
:
{exp:stash:set
name = "st_page_content"
parse_tags = "yes"
unprefix = "my_prefix"
}
{stash:st_entry_id}{entry_id}{/stash:st_entry_id}
{stash:st_page_content}
{exp:channel:entries
channel = "channel_short_name"
limit = "1"
require_entry = "yes"
}
<p>{title}</p>
{if my_prefix:no_results}<p>no results</p>{/if}
{/exp:channel:entries}
{/stash:st_page_content}
{/exp:stash:set}
EE 2.9.2
Stash 2.6.1 (Dev)