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 as expected

July 11, 2012 1:38pm

Subscribe [2]
  • #1 / Jul 11, 2012 1:38pm

    Mixpo

    25 posts

    Hi,

    I know there’s a simple answer somewhere but it’s eluding me. On a blog-type page I have a space for a thumbnail which can be either an image or an embedded video. In the channel entry the thumbnail image is a required field (the image is used elsewhere in the blog) but the video entry is optional. The key is, if a video tag is entered in the channel entry, I want it to take the place of the image in the thumbnail spot. Otherwise I want the image to show. Here’s the code that I expected would do just that:

    <div class="post_thumbnail">
    {if thumbnail_video != ''}
    {thumbnail_video}
    {if:else}
    {thumbnail_image}
    {/if}
    </div>

    This code, however, always defaults to the thumbnail image and never shows the video. Before the image was a required field (in other words, if there was just one or the other, but not both) I was able to use this code to generate the correct thumbnail:

    <div class="post_thumbnail">
    {if thumbnail_image}
    {thumbnail_image}
    {/if}
    {thumbnail_video}
    </div>

    How do I check to see if there is content in the thumbnail_video channel field and show that instead of the image?

    Thanks to all in advance,

    Mignonne Maxwell

  • #2 / Jul 11, 2012 3:28pm

    Mixpo

    25 posts

    Anyone willing to take a stab at advising on this?

  • #3 / Jul 11, 2012 5:42pm

    Mixpo

    25 posts

    Anyone?

  • #4 / Jul 11, 2012 5:58pm

    Mixpo

    25 posts

    Never mind,

    I figured it out. EE didn’t know what to make of the video content in the field. When I replace the video with static text it works fine.

    Mignonne

  • #5 / Jul 12, 2012 3:45am

    silenz

    1651 posts

    I do mind.
    Had a similar issue the other day. The field did contain a javascript tag and the conditional whether the field is empty failed as well.
    Is this a bug?

  • #6 / Jul 12, 2012 3:00pm

    Shane Eckert

    7174 posts

    Hey silenz,

    Can you show me your code that is not working as expected?

    Thank you,

  • #7 / Jul 12, 2012 5:08pm

    silenz

    1651 posts

    {if my_field}{my_field}{if:else}foobar{/if}

    Now if {my_field} contains

    <scr*pt src=“something.js”></scr*pt>

    the above conditional will render:

    foobar

    .

    If I add one whitespace after the closing script-tag the condintional will render the contents of the field as expected.

  • #8 / Jul 16, 2012 10:47am

    Shane Eckert

    7174 posts

    Hey silenz,

    I was able to reproduce this with your steps given above. That is so odd.

    I filed a bug on this. Please comment on the bug to stay up to date on the eventual release it will be fixed in and any quick fixes the Devs come up with.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases