0

Is there a way to select parents from multiple child entry ids? For example, I have a blog channel with a playa relationship,via a blog_staff field, to a people channel (to identify authors of blog entries) and a team channel with a playa relationship, via a team_members field, to people as well (to group them into teams). I tried to query for blog entries of multiple people but seem to be limited to only one.

I tried the playa field feeding the people entry_ids through an embed to a parents field to grab the associated blog entries:

{team_members}
    {embed="includes/.bp_by_staff" entry_id="{entry_id}"}
{/team_members}

The .bp_by_staff template trying to use those people entry_ids to look up their blog posts:

{exp:playa:parents channel="blog"  entry_id="{embed:people}"}
    {title}
{/exp:playa:parents}

Now, if {embed:people} is just one entry_id, say "18", this works great, the blog posts get found. But if {embed:people} yields multiple entry ids (the team has more than one person), say "18|29", it doesn't work.

Looking through the profiler for the generated sql of the failing case, one can see why. It seems like including more than one entry_id breaks the sql query which uses "=" rather than " in " for the where clause:

SELECT DISTINCT(rel.parent_entry_id) AS entry_id
FROM exp2_playa_relationships rel 
WHERE rel.child_entry_id = 18|29

If the where clause were using "in" as in WHERE rel.child_entry_id in (18, 29) the query works correctly.

Anyone find a workaround for getting results for multiple entry_ids ?

1

Did you try the coparents tag? Isn't this what it's for?

| improve this answer | |
0

Revising my answer, The multiple entry_ids issue was addressed, in version 4.2. Upgrading Playa seems to resolve it. Templates used:

{embed="includes/.nested-entries" entry_ids="{team_members:child_ids}"}

and .nested_entries embed would take the entry_id and look up the blog written by that "people" entry:

{exp:playa:parents entry_id="{embed:entry_ids}"  channel="blog"  field="blog_staff"  orderby="date"
limit="10" disable="member_data|categories" paginate="bottom" }

    {title}

 {pagination_links}

{/exp:playa:parents}

Side point, needing paginagion links, i made sure they weren't disabled by explicitly specifying what to disable.

| improve this answer | |

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.