2

Is it possible to show the order by number that a child entry is placed into a relationships field of a parent entry? I'm creating a top 100 list of movies and I want to show what number a person has ranked that movie in their list.

So for the Person Channel Entry there's a relationship field where Movie Channel Entries can be added. On the frontend I can display a {count} number on a Person page that shows where that movie is placed in their list:

{person_film_list channel="films"}
    {person_film_list:count}
    {person_film_list:title}
{/person_film_list}

The above renders as 1. Movie1, 2. Movie2, etc.

But on the Movie page I can't reference the count that the movie is placed on the Person's list:

{parents channel="person" field="person_film_list"}
        {parents:count}
        {parents:title}
{/parents}

The above renders as 1. Person1, etc. no matter what placement the movie has in the relationships field of the Person parent entry. I know it's doing this because it's using the count of the Person parent entry instead of the Movie child entry. Is it possible to reference the count of the current Movie entry being viewed in relation to it's location in the Person parent entry relationships field?

1

You should be able to get the count of the movie within the person_film_list relationship field by going one step further in your relationship drill down. When you get to the parent entry, add in a (child) relationship tag pair for the person_film_list field:

{!--   a movie entry   --}
{exp:channel:entries
    channel="MOVIES"
    dynamic="no"
    entry_id="ENTRY_ID"
    status="not closed"
}

    {!--   find all parent entries in the persons channel for this movie   --}
    {parents channel="PERSONS" field="person_film_list" status="not closed"}

        {!--   while on this persons entry, get the content of the person_film_list field   --}
        {parents:person_film_list status="not closed"}

            {!--   while looping through the content of the person_film_list field, only work with the movie we're targeting   --}
            {if title == parents:person_film_list:title}
                <p>
                    Movie Title: {title}<br>
                    Person Title: {parents:title}<br>
                    Movie's Count in Person's list: {parents:person_film_list:count}
                </p>
            {/if}

        {/parents:person_film_list}

    {/parents}
{/exp:channel:entries}
| improve this answer | |
  • Would it be possible to restrict/limit the nested loops (subqueries) with the use of an url_title or entry_id? – GDmac Dec 16 '13 at 10:49

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.