I want to set a condition in a channel:entries loop whereby a chunk of content is displayed if the entry has a particular relationship with another particular entry. In other words, I want to say: "IF this entry has a relationship with entry 1, show X. IF this entry has a relationship with entry 2, show Y"...

How would I achieve that?


Maybe I'm missing your meaning, but this should work:

    {if relationship_field:entry_id == "1"}
        // Show X
    {if relationship_field:entry_id == "2"}
        // Show Y

Note that this only accounts for parent-child relationships made within the entry you're currently viewing. To do the same for child-parent relationships, you'd need to do something similar with the parents tag.

  • Yes, I think this is doing exactly what I need. Simpler than I thought, thank you. – Matt Obee Jul 24 '13 at 12:47

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.