2

I have problem with related entries. I want to get related entries into a related entry. We are a travel agency and want to show selected travel packages in a "deals template".

Channels are:

deals, travel_packages, destinatios

Deals deal_01 relationship (to travel_packages) deal_01 relationship (to travel_packages) deal_01 relationship (to travel_packages) deal_01 relationship (to travel_packages) deal_01 relationship (to travel_packages)

travel_packages

date        text input
price       text input
taxes       text input
date        date
destination relationship (to destinations)
hotel       text input      

destinations

pictures_name   text input
maps        text input
description textarea

In "deals" template we have 5 relationship fields than are related with travel_packages. In deals template we chose the deals that we want to show.

Then in the template we have the follow code:

{exp:channel:entries channel="deals"} {related_entries id="deal_01"} Date: {date} (travel_packages field) Price: {price} (travel_packages field)

Here we want to show travel_packages relationship with destinations channel

we want to show {title} {pictures_name} {maps} Description: {description} But those tags are from destinations channels.

{related_entries} {/exp:channel:entries}

We tried to use related_entries again:

{related_entries id="destination"} {title} {pictures_name} {maps} Description: {description} {/related_entries}

but it doesn't work.

Thanks in advance.

2
  • 3
    Which EE version are you using? The relationships fieldtype was replaced with a greatly improved version in 2.6.0. I would strongly recommend updating before attempting to mess with relationships of any level of complexity. Sep 25 '13 at 2:17
  • Indeed, it is crucial you advise which version of EE you are using as the answers pre- and post-ee.2.6.x are wildly different. But relatively simple. Please re-engage for an answer :)
    – 3Easy
    Sep 26 '13 at 11:19
1

Guessing by the style of relationship tags you are using the best way to do this is to use an embed.

Steps:

1.) Create a template with the code for the destinations with an embed variable in the entry_id section.

{exp:channel:entries channel="destinations" entry_id="{embed:eid}"}
     <h1>{title} Related to the Package Deal</h1>
{/exp:channel:entries}

2.) Put that embed inside your travel package related entries loop with the entry id of the package in a eid variable you pass to the embed variable.

{exp:channel:entries channel="deals"} 
  {related_entries id="deal_01"}
     Date: {date} Price: {price}
     {embed="path/to/embed/template" eid="{entry_id}"}
  {/related_entries}
{/exp:channel:entries}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.