I'm building what I imagine to be a fairly stock-standard page template on a very standard EE setup.
I'm attempting to use EE 2.6.1's new native Relationships field type to link articles to each other, and to pages from another channel.
What I need to do is check if there are any related articles for the current page/article before I spit out the related content (if it's there). This is mainly so I can show or hide the "Related Articles" as appropriate.
My basic code looks like this:
{if related_articles}
<h3>Related Articles</h4>
{related_articles}
{related_articles:title} (etc...)
{/related_articles}
{if:else}
There are no related articles.
{/if}
This just returns the message about there being no related articles.
However, if I take the {related_articles}
loop out of the conditional, it performs exactly as expected.
This type of check would work just fine with any other type of channel field variable, so I'm a little confused as to why it's not working here.
I've checked over the official Relationships documentation a couple of times, but it doesn't seem to mention this type of scenario.
Am I doing something wrong, or missing something obvious? Is this something that can be achieved with EE's new native relationships?
Update: Ok, shortly after posting this I found this question, the answer to which helped me out.
I find the solution to be a little messy (nesting my title and any opening and closing DIVs within the loop itself - potentially necessitating multiple conditionals within the loop) but it gets the job done.