Hello. I am struggling to create a nested conditional that performs different actions depending on whether there are any entries in a channel for which a custom date field value (“events-date”) is in the future. Here is what I want to accomplish in plain English:
Step 1. For all events-date > current_time, list event
Step 2. If no entries exist with events-date > current_time, display “there are no upcoming events”
Below is the code I have so far, which successfully accomplishes Step 1 above:
<h3>Upcoming Events</h3>
<p> {exp:channel:entries status="{env_status}" channel="events" category="not 43" dynamic="no" paginate="bottom"}<br />
{if events-date > current_time}<br />
<ul class="news-updates"><br />
<li> <br />
{events-date format="%F %j%S, %Y"}<br />
<a href="http://{page_url}">{title}</a><br />
</li><br />
</ul><br />
{/if}<br />
{/exp:channel:entries}However, if there are no entries that meet the criteria, the listing will be blank. What I can’t figure out how to do is display an alternate message if there are no entries with future events-date. Note that there are many entries in the channel with events-date in the past, so I can’t just do “{if no_results}...” within the exp:channel:entries tag pair. Logically, it would have to go within the {if events-date > current_time} statement, but that does not work (nothing is displayed). Here is what I tried, without success:
<h3>Upcoming Events</h3>
<p> {exp:channel:entries status="{env_status}" channel="events" category="not 43" dynamic="no" paginate="bottom"}<br />
{if events-date > current_time}<br />
{if no_results}<br />
There are currently no upcoming events scheduled. To subscribe to email updates, click <a href="/subscribe">here</a>.<br />
{/if}<br />
<ul class="news-updates"><br />
<li> <br />
{events-date format="%F %j%S, %Y"}<br />
<a href="http://{page_url}">{title}</a><br />
</li><br />
</ul><br />
{/if}<br />
{/exp:channel:entries}Alternatively, I wonder if there’s any way to use the “search:field_name=” parameter to filter out events-date values before current_time.
I hope I’m explaining my issue clearly; I’ll be happy to offer any clarification that is needed.
Thank you,
-Michael