1

Is it possible to do conditionals for embeds? For example,lets say I have this very simple template, test/foo

{if foo}
   yes
{if:else}
   no
{/if}

In other templates, I want to use this embed in a conditional.

{if '{embed="test/foo"}' == 'yes'} Output is yes {if:else} Output is no {/if}

Unfortunately, when I tried this approach, what I got was always a no, even if I set test/foo template to yes.

Am I doing something wrong? Or is this just not possible?

1
  • Why are you trying to do this? Explain a little better, please.
    – Sobral
    Nov 26 '13 at 11:54
4

This way is not possible because of ExpressionEngine’s Parse Order

  1. Parse advanced conditionals
  2. Process embedded templates

With your code you don't have "yes" in conditionals when EE parses it, you have "{embed="test/foo"}"

2
  • Is there any alternatives to achieve this? Nov 26 '13 at 2:40
  • is dependent to what exactly you have in embed template and why do you need to use it this way.
    – Max Lazar
    Nov 26 '13 at 2:53
0

You should be able to do what you're looking for with Stash, using stash:embed. With the Stash embed you should be able to manipulate the process and parse stage so that it will run before the advanced conditional (see Max's answer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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