2

Is it possible to simply retrieve the entries from a Playa field that are in use?

Let's say I have a Team channel with everyone in the company's bio. 5 of those people have been selected across various Blog channel entries as the author. (In this case, a different person is logging in to post the entries, and we want to link to their bios.) Can I, with one tag, simply fetch the Team entries that are actively selected within Blog entries, in a sidebar without having a Blog entry as context?

Thanks!

Mark

1 Answer 1

1

Would the {exp:playa:parents} tag do the trick?

Essentially your looking for all of the entries (parents) which have a team member set to be the author. You could loop over your team members (or potentially one member, if it's the member permalink page) and then use the {exp:playa:parents} tag to pull your specific articles. The parents tag also supports all standard channel:entries tags, so you could do further refining with the search parameter if necessary.

http://docs.pixelandtonic.com/playa/templating/module/parents.html

Update: Updating my answer after clarification

What about adding something like this, which would be cached to help performance?

{exp:stash:set_list name="members"}
  {exp:channel:entries
  channel="blogs"
  search:member="not IS_EMPTY"}

  {stash:name}{member_name}{/stash:name}

  {/exp:channel:entries}
{/exp:stash:set_list}

{exp:stash:get_list name="members" unique="yes"}
  {name}
{/exp:stash:get_list}

So in the above code, we're pulling back all blogs that have the member field not empty. You'll notice this loop has a {stash:set_list} surrounding it which lets us store each item in a list.

After that chunk of code we use the {stash:get_list} to pull back our list of names, and we specify the unique parameter so we don't return multiple names that are the same.

I didn't test the above code, so definitely check the syntax, but hopefully that would work. Also, check the stash docs for more info on those tags, https://github.com/croxton/Stash/wiki

4
  • 1
    Thanks for the reply! Unfortunately, I'm looking for the opposite - My context is the blog landing page, not a specific entry, and I just want to display team members who have been related to blog posts - ANY blog posts. None of the P&T tags seem to support just referencing a channel; The're all channel entry tags outputting reverse relationships by entry. Commented Oct 16, 2013 at 16:54
  • So lets say you have 20 total team members, 5 of which have been assigned to any collection of blog posts, you want to display just those 5 members?
    – Bryant
    Commented Oct 16, 2013 at 19:00
  • Bingo. That's right, Bryant. Commented Oct 17, 2013 at 11:53
  • I updated my post with a potential method, let me know if that's in the ballpark
    – Bryant
    Commented Oct 17, 2013 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.