I have a Playa relationship between my "News" and "Projects" channels. In a News entry, you can select a related Project, so "News" is the parent and "Projects" is the child.
I have the following code on my Project template, and it works correctly to show related News items. However, I would like to hide the entire section when there are no related News items. I thought perhaps wrapping the section with {if no_parents}{if:else}...{/if}
would work, but I believe this type of statement must reside within the {exp:playa:parents ... }
tag pair.
{!-- TO DO: put in logic to hide block if no related news --}
<!-- Sidebar Related News -->
<h4>Related News</h4>
<ul>
{exp:playa:parents channel="News"}
<li><a href="{page_url}">{title}</a></li>
{/exp:playa:parents}
</ul>
<!-- Sidebar Related News::END -->
Is there something simple here I'm overlooking?
I am using ExpressionEngine version 2.5.3 and Playa version 4.4.2.
Thanks!