Retired Documentation:  You are using the documentation for version 1.7.3 which was retired in 2013. Go here for the latest version documentation or check here for your available upgrades to the latest version.

Reverse Related Entries
Find the Entries That Have a Parent Relationship With This One

What are Reverse Relationships?

NOTE: This documentation references the definitions and examples given in the Related Entries section. If you have not done so, please read that first.

An entry that has related entries is called the parent or primary entry. The entries that are being related to are called its children. In the example given in the Related Entries documentation, the events would be the parents as they are pulling in the data from the performer entries, which are the children. A Reverse Relationship would be the child entries displaying all of the parent entries that have created a relationship with it. Thus, a performer entry would be able to display any and all events at which the band has played.

Displaying Reverse Relationships

1. Add Related Entry Tags to your Template

To show a related entry, you will use the following tags:

{reverse_related_entries orderby="title"}

{/reverse_related_entries}

Note: Unlike the Related Entries tag, the Reverse Related Entries tag does not contain an id parameter as there is no need. However, it does support six of the typical parameters used by other ExpressionEngine tags:

{reverse_related_entries weblog="default_site" status="open" sort="desc" orderby="title" offset="5" limit="10"}

{/reverse_related_entries}

In this way, you can grab reverse related entries from specific weblogs with a certain status while sorting and ordering as you see fit. As Relationships are cached in order to reduce the load on ExpressionEngine, these are the only parameters available at this time.

Important: The above tags must be placed inside your {exp:weblog:entries} tag.

Here is an example showing the related entries tags inside your weblog entry tags:

{exp:weblog:entries weblog="performers" limit="15"}

<h3>{title}</h3>

{body}

{reverse_related_entries sort="desc" orderby="title"}
 <h2>{title}</h2>
 {body}
{/reverse_related_entries}

Submitted on: {entry_date format='%M %d, %Y'}

{/exp:weblog:entries}

{if no_reverse_related_entries} Conditional

The {if no_reverse_related_entries} conditional allows you specify certain content to be displayed when an entry does not have a related entry for the field specified.

{exp:weblog:entries weblog="performers" limit="15"}

<h3>{title}</h3>

{body}

{reverse_related_entries sort="desc" orderby="title"}
 {if no_reverse_related_entries}
  <h2>No Events for This Performer</h2>
 {/if}
 <h2>{title}</h2>
 {body}
{/reverse_related_entries}

Submitted on: {entry_date format='%M %d, %Y'}

{/exp:weblog:entries}

What Type of Reverse Related Data can be Displayed?

Nearly anything that is available in the weblog entries tags can be shown as reverse related data.

Important:  For performance reasons all related entry data is cached internally by the system when you submit new entries using the Publish page. This has the unfortunate side effect of making a some items that are normally dynamic not able to be used. These include various statistical variables:

{view_count_one}
{view_count_two}
{view_count_three}
{view_count_four}
{expiration_date }
{comment_expiration_date}
{recent_comment_date}
{comment_total}
{trackback_total}

Top of Page