1

I have a "videos" channel that has a one-to-one relationship with a "person" and a one-to-many relationship with other videos in the same channel. I am trying to display the information about the person and the related videos with a template like this.

<Videos>
    {exp:channel:entries channel="videos"}
    <Video>
        <Subject>{person:title}</Subject>
        <Affiliation>{person:affiliation}</Affiliation>
        <RelatedVideos>
            {related}
            <VideoId>{related:person:title}</VideoId>
            {/related}
        </RelatedVideos>
    </Video>
    {/exp:channel:entries}
</Videos>

This results in:

<Videos>
    <Video>
        <Subject/>
        <Affiliation/>
        <RelatedVideos>
            <VideoId>title 1</VideoId>
            <VideoId>title 1</VideoId>
            <VideoId>title 1</VideoId>
        </RelatedVideos>
    </Video>
</Videos>

Note the empty <Subject/> and <Affiliation/>.

However if I change the template to exclude the related video person:

<Videos>
    {exp:channel:entries channel="videos"}
    <Video>
        <Subject>{person:title}</Subject>
        <Affiliation>{person:affiliation}</Affiliation>
        <RelatedVideos>
            {related}
            {!-- <VideoId>{related:person:title}</VideoId> --}
            {/related}
        </RelatedVideos>
    </Video>
    {/exp:channel:entries}
</Videos>

I get this:

<Videos>
    <Video>
        <Subject>title 1</Subject>
        <Affiliation>affiliation 1</Affiliation>
        <RelatedVideos></RelatedVideos>
    </Video>
</Videos>

It seems I can get either the person related to my entry, or the person related to the other entries related to this entry. How can I get both?

1

I'm a little confused as to your channel and channel fields setup, but think you might be missing something if I am understanding.

Since person is a relationship field then you should add the person tag pair.

<Videos>
    {exp:channel:entries channel="videos"}
    <Video>
        {person}
        <Subject>{person:title}</Subject>
        <Affiliation>{person:affiliation}</Affiliation>
        {/person}
        <RelatedVideos>
            {related}
            <VideoId>{related:person:title}</VideoId>
            {/related}
        </RelatedVideos>
    </Video>
    {/exp:channel:entries}
</Videos>
1
  • I actually do have that tag pair in my template, but the behavior seems to be the same with or without it, so I removed it in my question to reduce it to the smallest possible example. The video has a one-to-one relationship to a person. The video also has a one-to-many relationship with other videos. Things break if I try to show the title of the person related to the child video that's related to the parent video. If I change the commented line to {related:title}, the related video title shows fine. But I want the person title, which seems to cause trouble. Nov 7 '13 at 17:47

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.