ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

reverse_related_entries dilema

June 25, 2009 7:19am

Subscribe [2]
  • #1 / Jun 25, 2009 7:19am

    timur

    1 posts

    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}
  • #2 / Jun 25, 2009 12:07pm

    e-man

    1816 posts

    What if you replace:

    Total number of events: {total_entries}

    with

    {if count == "{total_entries}"}
    Total number of events: {total_entries}
    {/if}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases