Having a bit of trouble getting my head round something in Playa...
I have code which is a bit like this to deal with multiple channels from a single Playa field:
{exp:channel:entries channel="my_channel" limit="1"}
<h1>{title}</h1>
{exp:playa:children field="my_playa_field"}
{if '{channel_short_name}' == 'channel_one'}
<section>
<h1>{title}</h1>
{channel_one_specific_field}
<section>
{if:elseif '{channel_short_name}' == 'channel_two'}
<section>
{title}
{channel_two_specific_field}
</section>
{/if}
{/exp:playa:children}
{/exp:channel:entries}
There are more than two channels, and each has a number of custom fields, but the basic idea is the same. It works, but what I'd like to do to make maintenance a bit easier is take all the code between the if statements and call them as embeds instead:
{exp:channel:entries channel="my_channel" limit="1"}
<h1>{title}</h1>
{exp:playa:children field="my_playa_field"}
{if '{channel_short_name}' == 'channel_one'}
{embed="templates/template_one"}
{if:elseif '{channel_short_name}' == 'channel_two'}
{embed="templates/template_two"}
{/if}
{/exp:playa:children}
{/exp:channel:entries}
I've tried this, and it doesn't work. The right templates are being called, but the tags aren't being parsed as I would like, e.g. {title} echoes '{title}' rather than 'Entry title.'
So really I have three questions:
- Is this a sensible approach to take to using Playa fields?
- What am I missing with the embed template code?
- Will calling embedded templates harm performance, or would I be better keeping all the code in one template (which is what I'm doing now)?