EE 5.2.2

I have a homepage channel with a primary entry that handles a bunch of stuff on the homepage. One of the things it has is a relationship field called featured movie that can have just one of any entries in the movie channel set to it.

What I am trying to do in my template is

  1. check if there is a featured movie set and then
  2. check if that featured movie has a video id set to it. If it does, display a carousel with an image and a YouTube embed, if not just show the image.

Here's how the section looks.

    {exp:channel:entries channel="homepage" limit="1"}
        {if featured_movie}
            <div class="series_program_section w-16">
                <div class="w-8">
                    <a href="/calendar/movie/{featured_movie:url_title}" style="text-decoration: none;">
                        <div class="links_container">
                            <a href="/calendar/movie/{featured_movie:url_title}">Explore this movie</a>
                <div class="w-8">
                {if featured_movie:video_id != ''}
                    <section class="carousel">
                        <div class="owl-example owl-carousel">
                            <div class="item">
                                <img class="main_image" src="{featured_movie:image}" alt="{featured_movie:title} image">
                            <div class="item">
                                <iframe width="100%" height="315" src="https://www.youtube.com/embed/{featured_movie:video_id}" frameborder="1" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"></iframe>
                            <img class="main_image" src="{featured_movie:image}" alt="{featured_movie:title} image">

To me, this looks like it should work just fine. But what's happening is that {if featured_movie:video_id != ''} is always returning false even when there is a video_id set. I have tested this by putting {featured_movie:video_id} before the conditional and watching the id render on the page but not return the code for when that condition is true.

I've tried other options for the conditional such as {if featured_movie:video_id:count == 1} and {if featured_movie:video_id:no_results} and none of them seems to work.

What am I missing? Is there some special way of doing conditionals for the fields in a relationship entry?


Although it is technically less efficient, you should try embedding it to render as a tag in the conditional like so:

{if '{featured_movie:video_id}' != ''}

Try that. As in the docs, if it isn't working as expected, you should try this route. You can read up more here:


It is at least kind-of documented now, but for years us EE folks knew it as a secret trick for when conditionals are acting wonky.

| improve this answer | |
  • 1
    Thank you @jrothafer. This is the correct answer and saves me a lot of time and heartbreak. It's good to know this "one secret trick to get your relationship conditional working!" Marked as the accepted answer, and thanks again. – Shayne Jun 21 '19 at 15:34

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.