0

I have 3 channels

City

-Name of City(Title)

University

-Name of School(Title) -Address -City(Relationship Field With City Channel)

Professor

-Name of Professor(Title) -University Name (Relationship field with University Channel) -Gender -Salary -Experience

Now What I have to do is On City Page I have to list all University and when i click on that university then on that University Page I have to show all Professor teaching in that University

The Code I am using is

  {exp:channel:entries channel="university" limit="1" url_title=segment_2}
  {title}
  {address}
  <table>
  {relationship_field="universityname"}
  <tr>
  <td class="gender">{if relationship_field:gender == 'M'}<span class="male"></span>{if:else}<span class="female"></span>{/if}</td>
  <td>{relationship_field:title}</td>
  <td>{relationship_field:experience}</td>
  <td>${relationship_field:salary}</td>
  </tr>
  {/relationship_field}
  </table>

But for some reasons i cant get the value of Professor Channel. Please Help

2 Answers 2

3

Since the Professor is the one with the relationship field then Professor > University is a Parent > Child relationship. So if you're in a University (Child) entry you need to use the parents tag for the relationship to get the opposite relationship, so something like this should work:

{exp:channel:entries channel="university" limit="1" url_title=segment_2}
    {parents field="universityname"}
        <tr>
            <td class="gender">{if parents:gender == 'M'}<span class="male"></span>{if:else}<span class="female"></span>{/if}</td>
            <td>{parents:title}</td>
            <td>{parents:experience}</td>
            <td>${parents:salary}</td>
        </tr>
    {/parents}

More about parents in the EE relationship docs.

0
0

I'm guessing that the relationship field that points to the University in the Professor channel is called "universityname". If so, you are getting a bit confused about how to access the relationship field contents.

The code you want is like this:

  {exp:channel:entries channel="university" limit="1" url_title=segment_2}
  {title}
  {address}
  <table>
  {universityname}
  <tr>
  <td class="gender">{if universityname:gender == 'M'}<span class="male"></span>{if:else}<span class="female"></span>{/if}</td>
  <td>{universityname:title}</td>
  <td>{universityname:experience}</td>
  <td>${universityname:salary}</td>
  </tr>
  {/universityname}
  </table>

HTH

1
  • Sorry, but i already have tried this. This gives me following output:{universityname}{/universityname} {universityname:title}{universityname:experience}{universityname:salary} Oct 27, 2016 at 11:21

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.