1

Within my channel entries loop, I'm trying to determine if an entry has FAqs; which in this situation are the parent as you choose an entry in the FAQ.

This is what I have: {if '{exp:playa:total_parents channel="faqs" entry_id="{entry_id}"}' > 0}

Which works-ish. It returns true for entries with no parent FAQs too. What am I doing wrong?

edit:

Parse order is set to input due to having some necessary PHP.

{exp:channel:entries channel="products" entry_id="<?php echo $entry_id; ?>" limit="1" dynamic="no" disable="categories|member_data|pagination"}
    {if {exp:playa:total_parents channel="faqs"} > 0}
        blah blah
    {/if}
{/exp:channel:entries}  

Blah blah in this particular case returns whether or not there actually are FAQs.

2
  • Ryan, I think you may have some terminology reversed. Can you post a screenshot of one of your channel entries with a Playa relationship selected, as well as ore of your template code? Version numbers (EE and Playa) would help as well!
    – Lisa
    May 8 '13 at 16:21
  • The relationship is made in the FAQ entry. Based on the playa table, the FAQ is parent to the device. I choose a device that the FAQ pertains to. My template looks much like what Jean responded with below. EE v2.5.5; Playa v4.4.2
    – Ryan Shrum
    May 8 '13 at 18:00
1

If your total_parents loop is inside your entries loop, you shouldn't need the entry id param since it defaults to that. So you should be able to do this:

{exp:channel:entries channel="my_channel" limit="1" dynamic="no" disable="whatever|not|needed" orderby="date" sort="desc"}
    {if '{exp:playa:total_parents channel="faqs" dynamic="no" disable="whatever|not|needed" orderby="date" sort="desc"}' > '0'}
        whatever you want if there are parent entries
    {/if}
{/exp:channel:entries}

This works only if the playa field is in the FAQ field group and that field is assigned to the channel used by your loop - is that where you have it?

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.