I’m trying to get my head around reverse related entries and how to best display our information.
I basically have 2 weblogs:
- companies
- events
I’d like to display past and future events for a company and have created a few templates with the code below.
Basically drawing up an individual company from the ‘companies’ weblog and displaying upcoming events via reverse_related_entries.
One issue I have is that reverse_related_entries doesn’t take expiration_date into account, so a company with no future events just shows up as blank.
no_reverse_related_entries doesn’t work, as the company has past events, so I’m not able to show something like “This company has no forthcoming events listed”. Anyone got any idea on how to do this?
The second thing I’d like to do is show the total number of reverse_related_entries and I’ve tried {total_entries} - but if there are more than 1 event, I get Total events: showing up for each event, ie more than once.
Thanks for your help.
Timur
{exp:weblog:entries orderby="company_name" weblog="company_intelligence" limit="1"}
<span class="purpleheading"><strong>Upcoming events</strong></span>
{reverse_related_entries weblog="events" orderby="entry_date" sort="asc" show_future_entries="yes"}
{if entry_date > "{current_time}"}<a href="http://{title_permalink=events/details}">» {title}</a>
<strong>{event_date format="%d %F %Y"}</strong>
Location: {event_city}{/if}
Total number of events: {total_entries}
{/reverse_related_entries}
{/exp:weblog:entries}