1

I am using EE 2.6.1 with a relationship field. The two entries in the venue related entry (telephone and email) are not mandatory fields, so the way I would usually do it is wrap it in an if statement and only display if the field is populated. Like so:

<div class="contact-details">
            {if course-venue:telephone}<p>Telephone: {course-venue:telephone}</p>{/if}
            {if course-venue:venue-email}
                <p>Email: {encode="{course-venue:venue-email}" title="{course-venue:venue-email}"}</p>
            {/if}
        </div>

Problem is that EE's native relationships field doesn't seem to work this way, does anyone know how I can achieve the same result? This just displays nothing.

Thanks in advance!

1 Answer 1

2

I hate to suggest it, but have you tried:

{if course-venue:telephone != ""}<p>Telephone: {course-venue:telephone}</p>{/if}

or alternatively

{if '{course-venue:telephone}' != ""}<p>Telephone: {course-venue:telephone}</p>{/if}

It seems like logically what you tried should work, but I've not used the new native relationship field to try something like this. You do of course have the chunk you included above wrapped in {course-venue} and {/course-venue}, right?

Does it return the right data without the conditional (i.e. for your other related custom fields in the related entry)?

3
  • I hadn't tried those. Your first suggestion didn't work but the second did. Also so does {if '{course-venue:telephone}'} - so thank you very much! Will accept this as the answer when the StackExchange allows me to!
    – Joe Beaver
    Commented Aug 22, 2013 at 15:34
  • It's unfortunate that it needed that revision - the result is a complex conditional, which isn't ideal for performance, but if it works, it works. Glad I could help. Commented Aug 22, 2013 at 15:42
  • @JeanSt-Amand, there isn't simple or advanced conditionals using modules variables. Simple conditionals are parsed before the modules and the advanced are parsed after them. Conditionals using tags or values of modules are always parsed after them or by its own parser.
    – Sobral
    Commented Aug 25, 2013 at 17:23

Your Answer

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

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