1

I must be looking at code for too long. I'm sure there's a simple solution to this.

I have a regular page entry, where I select an organization through a playa single select.
An organization entry can have people assigned to it.
I want to show the organization's people on my page entry.

This is my template:

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

  Displaying people in organization ID: {related_organization:child_ids}.

  {exp:playa:parents channel="people" entry_id="{related_organization:child_ids}"}
    {title}<br />
    {if no_parents}No results{/if}
  {/exp:playa:parents}

{/exp:channel:entries}

The playa field outside the tag shows me the correct child_ids.
The exp:playa:parents tag renders no results.
If I hard code the entry ID in the entry_id parameter, it works just fine.

If I do entry_id="4321|1234|{related_organization:child_ids}", I can see in my DB queries log that it is not even rendering {related_organization:child_ids} at all.
It shows ... WHERE rel.child_entry_id IN (4321,1234) ...

Adding parse="inward" doesn't have any effect.

Why isn't the tag working inside the parameter?

Update
Using an embed seems to work. But no one likes embeds anymore.
Using an equivalent stash embed doesn't work.

2
  • Is that your exact code? or dumbed down code? Also (not a great solution) but try passing IDs to an embed. If it's a parsing issue, that will get it working.
    – Anna_MediaGirl
    Sep 6, 2013 at 16:37
  • What I posted was what I dumbed my template down to. Still didn't work. Using an embed worked. Using the exact same thing in a stash embed didn't. Whaaaat. Sep 6, 2013 at 16:59

2 Answers 2

2

It's a parse order issue, related to the way Playa handles its fieldtype tags.

The Playa fieldtype actually takes its {related_organization:child_ids} tag and converts it into a module call: {exp:playa:child_ids field="related_organization"}, which the EE parser will then execute. So you are effectively doing this in your template:

{exp:playa:parents channel="people" entry_id="{exp:playa:child_ids field='related_organization'}"}

You can see why that wouldn't work.

I'd recommend using stash, rather than an embed:

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

  {exp:stash:set name="child_ids" parse_tags="yes"}
    {related_organization:child_ids}
  {/exp:stash:set}

{/exp:channel:entries}

{exp:stash:parse name="child_ids" process="end" parse_tags="yes"}
  {exp:playa:parents channel="people" entry_id="{stash:child_ids}"}
    {title}<br />
  {/exp:playa:parents}
{/exp:stash:parse}
1
  • My code example was already dumbed down - I've been using Stash for my real template. The shorthand to module tag was the lightbulb moment. Thanks Rob. Sep 6, 2013 at 17:24
0

Ok, figured it out.

The {related_organization:child_ids} is just shorthand for the {exp:playa:child_ids} tag pair.

Putting a tag pair inside a parameter was making it freak out.

So instead of using {related_organization:child_ids} as the entry_id parameter, I did this:

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

  {related_organization var_prefix="org"}
    {exp:playa:parents channel="people" entry_id="{org:entry_id}"}
      {title}<br />
    {/exp:playa:parents}
  {/related_organization}

{/exp:channel:entries}

Rob explains the same thing in his answer and recommends how to do it with Stash.

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.