I have a channel with a playa field where users can select a block of content to insert into a page.
Is there a way that I can specify a default child entry to display if the playa field is left blank?
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It only takes a minute to sign up.
Sign up to join this communityYes. One approach would be using a conditional based on no_children
variable:
{exp:playa:children field="your_field"}
{if no_children}
No children found...display fallback.
{/if}
{/exp:playa:children}
Or you might find that using a conditional based on the {exp:playa:total_children}
tag is better suited:
{if "{exp:playa:total_children field='your_field'}"}
No children found...display fallback.
Perhaps open a channel entry loop here to show your fallback child
{/if}