I have a grid field that contains a relationship field. I want to alter the output according to whether or not a particular field in the related entry contains data or not. For instance:
{if grid_field:relationship_field:related_entry_content_field != ""}Do this{if:else}Do something else{/if}
Instead of the expected results, it prints "{if" then seems to evaluate both conditions as true.
Any ideas on how to make this work?
Edit: Here are some examples of what works and what doesn't work:
{exp:channel:entries channel="channel_name" search:search_field="={segment_x}" dynamic="no"}
{grid_field}
{!-- Grid field, then relationship field, then field from the related entry - no tag pair. This works: --}
<h1>{grid_field:relationship_field:title}</h1>
{!-- Same syntax as above but used in a conditional. Does not work: --}
<h2>{if grid_field:relationship_field:title == "foo"}Foo{if:else}Not foo{/if}</h2>
{!-- Using tag pair for the relationship field as suggested below. This works: --}
{grid_field:relationship_field}
<h3>{if grid_field:relationship_field:title == "foo"}Foo{if:else}Not foo{/if}</h3>
{/grid_field:relationship_field}
{/grid_field}
{/exp:channel:entries}
Here is the output from the above code:
Title of Related Entry (Desired result from Line 4)
{ifFooNot foo (Weird result from Line 6)
Not foo (Desired result from Lines 8 - 10)
Hopefully this helps someone else!