Using Solspace Calendar, I am displaying a list of related entries (from a relationship field) on an individual event page, like so:
{exp:calendar:events event_id="{embed:event_id}"}
<section id="related-orgs">
<div class="hd">
<h2>Related Organisations</h2>
</div>
<div class="bd">
<!-- Start Entry Listing -->
<ul class="entries compact">
{event_organisations}<li class="entry"><a href="#">{event_organisations:title}</a></li>{/event_organisations}
</ul>
<!-- End Entry Listing -->
</div>
</section>
{/exp:calendar:events}
This is pulling through the related entries correctly.
However, if there are no related entries, I don't want that section to appear at all. I have tried using count
and total_results
as per the below, but this appears to prevent it from showing even when there are relationships.
{exp:calendar:events event_id="{embed:event_id}"}
{if event_organisations:count == "1"}<section id="related-orgs">
<div class="hd">
<h2>Related Organisations</h2>
</div>
<div class="bd">
<!-- Start Entry Listing -->
<ul class="entries compact">{/if}
{event_organisations}<li class="entry"><a href="#">{event_organisations:title}</a></li>{/event_organisations}
{if event_organisations:count == event_organisations:total_results}</ul>
<!-- End Entry Listing -->
</div>
</section>{/if}
Am I missing an obvious solution?