1

I have one channel called E. I have another channel called B.

I am trying to get my head around relationship in ee.

fields in channel E

  1. title
  2. url_title
  3. e_name
  4. e_description

fields in channel B

  1. title
  2. url_title
  3. e_tag_b(relate to event e_name or title)
  4. b_url

What I am getting in my last_segment is a url_title of channel E.Only this as my resource I want to get all the entries for channel B.

I read this doc,but i found it too confusing.

What I am doing :

{exp:channel:entries channel="B" }

    <h3>{e_tag_b:title}</h3>
    <p>{e_tag_b:b_url}</p>

{/exp:channel:entries}

I get consfused about what to loop when and which tag is to be related where.Any help?

2 Answers 2

1

It looks like you've forgotten to include your relationship field tag. Try this?

{exp:channel:entries channel="B" }

    {e_tag_b}
        <h3>{e_tag_b:title}</h3>
        <p>{e_tag_b:b_url}</p>
    {/e_tag_b}

{/exp:channel:entries}
2
  • you forgot the url title,this will give me all the entries
    – user2133
    Mar 25, 2014 at 12:12
  • Then I'm not sure I completely understand your question. If your last segment is a url_title of Channel E, then you could do a "parents" relationship field from Channel E to Channel B which would give you all the entries in Channel B which are related to the entry for the page you're on in Channel E. Alternatively you need to add dynamic="no" into your channel:entries tag which will give you every entry in Channel B despite being on a Channel E entry page.
    – JxM
    Mar 25, 2014 at 15:11
1

Not sure I understand the question well but here is my take on it:

  • Start with a url_title in your last segment
  • Find the entry in channel E corresponding to that url_title
  • Several entries in channel B are potentially related to that entry using the e_tag_b field. Following EE terminology, those entries are the "parents" of the entry in channel B
  • Get the titles of those "parents" entries.

Let's try this

{exp:channel:entries channel="E" url_title="{last_segment}" limit="1" require_entry="yes"}

    <h1>{title}</h1>

    <p>Related (parents) entries:</p>

    {parents channel="B" field="e_tag_b"}
        {if parents:count == 1}<ul>{/if}
            <li>{parents:title}</a></li>
        {if parents:count == parents:total_results}</ul>{/if}
    {/parents}

{/exp:channel:entries}

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.