ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Conditional statement not working

May 09, 2012 11:03am

Subscribe [2]
  • #1 / May 09, 2012 11:03am

    Wayne Smallman

    176 posts

    Hi,

    I’ve recently been tasked to add several items into a template, where I already have several conditional statements, such as:

    {if embed:product_video}{snippet_supplementary_video}{/if}

    However, the new conditional statement I just added won’t work:

    {if embed:title_shop AND embed:link_shop}
    HTML object…
    {/if}

    I’ve checked and double checked the entry and there is data in place. The field names are correct. Also, the field types are the same for both conditional statements. I’ve also tried OR and only one variable, but it still won’t work.

    I have a sneaking suspicion my time away from ExpressionEngine is showing!

    What am I missing?

  • #2 / May 10, 2012 12:17pm

    Shane Eckert

    7174 posts

    Hi Wayne,

    Thank you for posting your question here on the ExpressionEngine forums.

    The code did not work for me either!

    This did:

    {if 'embed:title_shop' AND 'embed:link_shop'}
    HTML object…
    {/if}

    Please let me know if that helps!

    Cheers,

  • #3 / May 10, 2012 12:32pm

    Wayne Smallman

    176 posts

    Hi Wayne,

    Thank you for posting your question here on the ExpressionEngine forums.

    The code did not work for me either!

    This did:

    {if 'embed:title_shop' AND 'embed:link_shop'}
    HTML object…
    {/if}

    Please let me know if that helps!

    Cheers,

    Shane, thanks for the reply!

    Yes, that worked, so a big thanks for that.

    However, why do I have to enclose the embed item names in single quotes here when I have other conditional statements in the same template working perfectly well without them?

  • #4 / May 10, 2012 12:33pm

    Shane Eckert

    7174 posts

    Hi Wayne,

    Are these other conditional complex conditionals? I believe that a complex conditional needs these.

    Cheers,

  • #5 / May 10, 2012 12:36pm

    Wayne Smallman

    176 posts

    Are these other conditional complex conditionals? I believe that a complex conditional needs these.

    I’ve provided an example in the starting post.

  • #6 / May 10, 2012 12:41pm

    Shane Eckert

    7174 posts

    Hi Wayne,

    Gotcha bro.

    So that is a simple conditional. Adding any other logic will make it Advanced.

    Does that make sense?

    Cheers,

  • #7 / May 10, 2012 12:46pm

    Wayne Smallman

    176 posts

    So that is a simple conditional. Adding any other logic will make it Advanced.

    Does that make sense?

    You mean OR / AND?

  • #8 / May 10, 2012 12:49pm

    Shane Eckert

    7174 posts

    Hi Wayne,

    Yes. Did you visit the link? It talks about the logic.

    Thanks,

  • #9 / May 10, 2012 1:12pm

    Wayne Smallman

    176 posts

    Did you visit the link? It talks about the logic.

    I just had a quick look.

    What I may do from now on is break out of the parser and run complex conditional statements in PHP, converting the variables beforehand.

    Shane, thanks for your valuable time!

  • #10 / May 10, 2012 1:57pm

    Shane Eckert

    7174 posts

    Hey Wayne,

    It’s my pleasure to help!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases