{if taxonomy != "" OR related_pages != "" OR related_posts != "" OR related_news != ""}
<footer role="contentinfo">
{if taxonomy != ""}
<div id="taxonomy" itemprop="taxonomy">
<h3>Category tags for this page</h3>
<ul property="dcterms:type">
{exp:tagger:tags entry_id="{entry_id}" orderby=”tag_name”}
<li>
<a href="/page/tag/{tagger:urlsafe_tagname}" rel="tag">{tagger:tag_name}</a>
</li>
{/exp:tagger:tags}
</ul>
</div>
{/if}
{if related_pages != ""}
<div id="related-pages">
{related_entries id="related_pages"}
<h3>{title}</h3>
{body}
{/related_entries}
</div>
{/if}
{if related_posts != ""}
<div id="related-posts">
{related_entries id="related_posts"}
<h3>{title}</h3>
{body}
{/related_entries}
</div>
{/if}
{if related_news != ""}
<div id="related-news">
{related_entries id="related_news"}
<h3>{title}</h3>
{body}
{/related_entries}
</div>
{/if}
</footer>
{/if}
So, I am looking to write conditional code which firstly will only show a footer element if any of taxonomy, related_pages, related_posts or related_news are not empty. Note that related_* are all relationship field IDs.
Within this if statement are nested conditional statements which will only show content blocks if the corresponding IDs are not empty. Unfortunately, it seems that EE doesn't see relationship fields as ever being empty, even when no related content has been selected.
Does anyone know of either what is parsed by the relationship field IDs when no content has been selected, or another workaround to handle what I am trying to do in this code?
Bit long winded, but...
{if "{taxonomy}" != "" OR
"{related_entries id="related_pages"}{entry_id}{/related_entries}" != "" OR
"{related_entries id="related_posts"}{entry_id}{/related_entries}" != "" OR
"{related_entries id="related_news"}{entry_id}{/related_entries}" != ""}
...
{if "{related_entries id="related_pages"}{entry_id}{/related_entries}" != ""}
...
{if "{related_entries id="related_posts"}{entry_id}{/related_entries}" != ""}
...
{if "{related_entries id="related_news"}{entry_id}{/related_entries}" != ""}
...
If your budget can stretch to it the Playa add-on is the King of relationships and makes working with relationships a breeze.