0

I'm building a site using relationships and have run into something that's got me stumped. I suspect it's something simple but can't for the life of me see what it is.

I have the following channels and fields:

Channel: training_course_dates
Field: training_course (single relationship to training_course_overview channel)

Channel: training_course_overview
Field: course_testimonial (single relationship to testimonials channel)

Channel: testimonials
Field: testimonials_quote

What I'm trying to do is to show an entry from the {training_course_dates} channel, pulling in the course overview information, including the related testimonial but this is where I'm getting stuck.

Here's the code I'm currently using:

{exp:channel:entries 
    channel="training_course_dates" 
    dynamic="yes" 
    url_title="{segment_4}"
    status="open" 
    limit="1"
    cache="yes" 
    refresh="1440"
}
    <div class="feature_box">
        <p>
            {training_course}   
                {training_course:course_testimonial}
                    {training_course:course_testimonial:testimonials_quote}
                {/training_course:course_testimonial}
            {/training_course}  
        </p>
    </div>
{/exp:channel:entries}

And here's what's getting output:

{training_course:course_testimonial}
{training_course:course_testimonial:testimonials_quote}
{/training_course:course_testimonial}

Any ideas on where I'm going wrong?

Thanks in advance,

Tom

2
  • I suspect the problem may be related to my use of opening and closing tags, which I believe are only required for multiple relationships. Sadly when I try to use a single tag {training_course:course_testimonial:testimonials_quote} I just get a blank white screen? Any help is appreciated! Jul 6, 2016 at 10:31
  • First thing would be to change the dynamic="yes" to dynamic="no" since you are selecting the entry by segment. did you try something like {training_course:entry_ids} {training_course} {training_course:course_testimonial:entry_ids} {/training_course} to see if you are getting entry ids? Jul 6, 2016 at 12:06

1 Answer 1

0

I've now managed to sort this one using an embed. Not the optimum solution for performance I know, but without being able to get the double layer of relationships to work this solution now does the job.

I used an embed on the main template and pass through the training course URL title to use in the embedded template like so:

{embed="/training/testimonial_embed" 
     training_course="{training_course}{training_course:url_title}{/training_course}"
}

I then use that information on the embedded template to display the required data like so:

{exp:channel:entries 
    channel="training_course_overview" 
    status="open" 
    limit="1"
    cache="yes" 
    refresh="1440"
    url_title="{embed:training_course}"
}
    <div class="feature_box">
        <p class="testimonial_quote">“{course_testimonial:testimonials_quote}”</p>
        <p class="testimonial_name">{course_testimonial:title}</p>
    </div>
{/exp:channel:entries}

Hope that helps anyone with a similar challenge.

Tom

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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