0

So I'm trying to conditionally display an embed within an entry based on several parameters: channel_short_name and category. So I have a conditional that checks a few items and then if it matches has an embed that passes along with it the categories that are in the entry.

Below is the template code I initially wrote. There are a couple of issues. 1. It has nested {categories} tags and EE doesn't like that and throws an error. 2. If I just remove the embeds for now (so that something at least renders), I can end up with multiple instances of the embed since the top {categories} tag is a loop and entries can have more than one category assigned.

So is there maybe a way I can just assign all the categories to a variable and use that instead of wrapping the whole thing in a {categories} tag?

{categories}
    {if channel_short_name=="webcast-partner" OR channel_short_name=="webcast-mssp" OR category_id==93}
        {embed="_includes/.resource-carousel1" cat="{categories backspace="1"}{category_id}|{/categories}"}
    {if:elseif channel_short_name=="webcast-customer"}
        {embed="_includes/.resource-carousel2" cat="{categories backspace="1"}{category_id}|{/categories}"}
    {if:elseif category_id==60}
        {embed="_includes/.resource-carousel3" cat="{categories backspace="1"}{category_id}|{/categories}"}
    {if:else}
        {embed="_includes/.resource-carousel4" cat="{categories backspace="1"}{category_id}|{/categories}"}
    {/if}
{/categories}

1 Answer 1

0

ok, figured it out:

{if channel_short_name=="webcast-partner" OR channel_short_name=="webcast-mssp" OR "|{categories}{category_id}|{/categories}"*="|93|"}
    {embed="_includes-v2/.resource-carousel1" cat="{categories backspace="1"}{category_id}|{/categories}"}
{if:elseif channel_short_name=="webcast-customer"}
    {embed="_includes-v2/.resource-carousel2" cat="{categories backspace="1"}{category_id}|{/categories}"}
{if:elseif "|{categories}{category_id}|{/categories}"*="60"}
    {embed="_includes-v2/.resource-carousel3" cat="{categories backspace="1"}{category_id}|{/categories}"}
{if:else}
    {embed="_includes/.resource-carousel4" cat="{categories backspace="1"}{category_id}|{/categories}"}
{/if}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.