Include-exists Tag
Checks if a view exists.
Overview#
You can use this tag to check if a view exists. Useful if you have some sort of dynamic loop.
{{ if {include:exists src="myview"} }}
It exists.
{{ else }}
It doesn't.
{{ /if }}
@if (Statamic::tag('include:exists')->src('myview')->fetch())
It exists.
@else
It doesn't.
@endif
Related Reading#
This tag goes hand in hand with the include tag.
You may be interested in the include:if_exists tag to simplify your template.
Parameters
src
string
required
The name of the view to check for. Example: src="cards/author_bio" or :src="var_name".