-
Notifications
You must be signed in to change notification settings - Fork 20
{exp:stash:not_found}
Outputs the 404 template configured in Design > Templates > Global Preferences
, with a 404 header and without changing the URL. An alternative to {redirect="404"}
which can be problematic when used in embeds, capturing content with Stash, or with other third-party caching add-ons.
{exp:channel:entries
channel="my_channel"
require_entry="yes"
}
{if no_results}
{exp:stash:not_found}
{/if}
{/exp:channel:entries}
ExpressionEngine only allocates the special {if no_results}..{/if}
conditional to the outermost module tag in a template which contains nested tag pairs. Unfortunately this means the conditional doesn't work in nested tags.
To address this issue, Stash tags such as {exp:stash:cache}
accept the unprefix=""
parameter to effectively 'hide' the conditional from the template parser until the point you actually need to use it. The parameter should be used by the immediate parent tag of the tag where you want to use the conditional:
{exp:stash:cache unprefix="nested"}
{stash:embed:views:layout}
{exp:channel:entries
channel="my_channel"
require_entry="yes"
}
{if nested:no_results}
{exp:stash:not_found}
{/if}
{/exp:channel:entries}
{/exp:stash:cache}
Getting started
Using Stash
Using Mustash
- Mustash
- Installing Mustash
- Managing variables
- Managing bundles
- Cache-breaking rules
- Mustash plugins
- Mustash Varnish plugin
- Mustash plugin development
- Mustash API
Template design patterns
Tag reference
- {exp:stash:set}
- {exp:stash:get}
- {exp:stash:block}
- {exp:stash:set_value}
- {exp:stash:append}
- {exp:stash:append_value}
- {exp:stash:prepend}
- {exp:stash:prepend_value}
- {exp:stash:copy}
- {exp:stash:context}
- {exp:stash:is_empty}
- {exp:stash:not_empty}
- {exp:stash:set_list}
- {exp:stash:get_list}
- {exp:stash:append_list}
- {exp:stash:prepend_list}
- {exp:stash:split_list}
- {exp:stash:join_lists}
- {exp:stash:list_count}
- {exp:stash:unset}
- {exp:stash:flush_cache}
- {exp:stash:bundle}
- {stash:embed}
- {exp:stash:extend}
- {exp:stash:parse}
- {exp:stash:cache}
- {exp:stash:static}
- {exp:stash:finish}
- {exp:stash:not_found}
- Short tag syntax
- Using Stash methods in your own add-ons