We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Add a relationship inside a relationship

How Do I?

Eastwood Design's avatar
Eastwood Design
605 posts
9 years ago
Eastwood Design's avatar Eastwood Design

I have a complex question.

I have 3 channels 1. members (zoo visitor) 2. Events 3. Institutions

An institution has a relationship to members (field is trainers) Events have a relationship to Institutions

a) When I post an event I want to display the Institution information.
b) Then also include the members (trainers) info

a) is working fine but I cant get the related field to members to display.

{exp:channel:entries channel="events" sort="asc" orderby"title" limit="1" disable="member_data" show_future_entries="yes" show_expired="no" dynamic="on" url_title="{segment_3}"}
          <h1 class="content-title">{title}</h1>
          
            <span>Organization:</span>
            {institution}
            {institution:title}
            </div>
            
            <div class="trainer-email">
            <span>Email:</span>
            {institution:institution_email}
            </div>
            
            <div class="trainer-email">
            <span>City:</span>
            {institution:institution_city}
            </div>
            <div class="trainer-email">
            <span>Street:</span>
            {institution:institution_street}
            </div>
            
            <div class="trainer-biography">
            <span>Web:</span>
            {institution:institution_web}
            </div>
            
            <div class="trainer-biography">
            <span>Desc:</span>
            {institution:institution_description}
            </div>
                                                
                                                <!-- show trainers info -->
                                                
                  {parents channel="members" field="trainers"}
                                <div class="show">
                                        <strong>{parents:title}</strong>
                                        <div class="what">{parents:trainer_city}</div>
                                        <div class="when">{parents:trainer_state}</div>
                                </div>
                            {/parents}
            
            
            {/institution}
    
   {/exp:channel:entries}

ref: AMI

       
Wes Baker's avatar
Wes Baker
343 posts
9 years ago
Wes Baker's avatar Wes Baker

So the problem is you need to specify you’re looking for parents of the institution:

<!-- show trainers info -->

{institution:parents channel="members" field="trainers"}
    <div class="show">
        <strong>{institution:parents:title}</strong>
        <div class="what">{institution:parents:trainer_city}</div>
        <div class="when">{institution:parents:trainer_state}</div>
    </div>
{/institution:parents}
       
Eastwood Design's avatar
Eastwood Design
605 posts
9 years ago
Eastwood Design's avatar Eastwood Design

I am a still a little confused to what field I need to reference here: field=”trainers”

Where field should I reference here?

Channel “events” field: institution (relationship, multi, with channel “training_institutions” )

Channel “training_institutions” Field: trainers (relationship, multi to members)

Channel: “members” Field: title, member_first_name, member_last_name

Severity: Warning

Message: array_merge() expects at least 1 parameter, 0 given

Filename: relationship_parser/Tree_builder.php

Line Number: 133
       
Wes Baker's avatar
Wes Baker
343 posts
9 years ago
Wes Baker's avatar Wes Baker

The field should specify the field name of the relationship that you want parents for. For instance, if your setup looked like this:

  • Channel: Events
    • Field: institution
  • Channel: Institutions
    • Field: trainers
  • Channel: Members

Then, this would be what gets you to that level:

{exp:channel:entries channel="events"}
    {institution}
        {institution:parents field="trainers"}
            {institution:parents:title}
        {/institution:parents}
    {/institution}
{/exp:channel:entries}
       
Eastwood Design's avatar
Eastwood Design
605 posts
9 years ago
Eastwood Design's avatar Eastwood Design

oddly getting this error using your code above on a blank empty template.

ee. ver 2.10.1

A PHP Error was encountered

Severity: Warning

Message: array_merge() expects at least 1 parameter, 0 given

Filename: relationship_parser/Tree_builder.php

Line Number: 133

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/user/admin/codeigniter/system/core/Exceptions.php:170)

Filename: core/Common.php

Line Number: 479
       
Eastwood Design's avatar
Eastwood Design
605 posts
9 years ago
Eastwood Design's avatar Eastwood Design

for what it is worth my members channel is a zoo visitor channel

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
9 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

I think it’s worth updating to the latest 2.x as there were several relationship bugs fixed in 2.11

       
Eastwood Design's avatar
Eastwood Design
605 posts
9 years ago
Eastwood Design's avatar Eastwood Design

Updated to EE2.11. this code is a little different than the original. (different template) I got the institutions to display properly on the events template.

Still cannot get my relationship to my members channel to display anything

Channel: channel=”training_institutions”

Field: directors (multi relationship field, related to the members channel)

Field: trainers(multi relationship field, related to the members channel)

Field: assistants (multi relationship field, related to the members channel)

Channel: channel=”members”

Field: member_first_name, member_last_name

{exp:channel:entries channel="training_institutions" sort="asc" orderby"title" limit="1" disable="member_data" show_future_entries="yes" show_expired="no" dynamic="on" url_title="{segment_3}"}
{title}
{categories} {category_name} {/categories}

<div class="trainer-biography">
<span>Directors:</span>
{directors}{directors:title}{directors:member_first_name} {directors:member_last_name}{/directors}
</div>
<div class="trainer-biography">
<span>Trainers:</span>
{trainers}{trainers:title}  {trainers:member_first_name} {trainers:member_last_name}{/trainers}
</div>

<div class="trainer-biography">
<span>Assistants:</span>
{assistants}{assistants:title}  {assistants:member_first_name} {assistants:member_last_name}{/assistants}
</div>
{/exp:channel:entries}
       
Wes Baker's avatar
Wes Baker
343 posts
9 years ago
Wes Baker's avatar Wes Baker

That’s a pretty basic relationship setup, so I’d expect that to work. What is the status of the members in the member channel? I’m assuming they’re not future or expired entries.

       
Eastwood Design's avatar
Eastwood Design
605 posts
9 years ago
Eastwood Design's avatar Eastwood Design

members channel entries are “open” and not future with no expiry

       
Wes Baker's avatar
Wes Baker
343 posts
9 years ago
Wes Baker's avatar Wes Baker

I’m sorry to keep asking obvious questions, but the entry that you’re pulling up has relationships, right? Everything you’re doing looks right to me. Do relationships to other channels work? Is it just the members channel that’s causing problems?

       
Eastwood Design's avatar
Eastwood Design
605 posts
9 years ago
Eastwood Design's avatar Eastwood Design

Thanks for you help.

the channel=”training_institutions” has relationship fields (directors etc) that are related to the members fields.

Other relationships work in other channels it just seems this members channel is not working.

       
Wes Baker's avatar
Wes Baker
343 posts
9 years ago
Wes Baker's avatar Wes Baker

Then I’m guessing something funny is going on with Zoo Visitor. Have you tried contacting them to see if this is a known issue?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.