1

I am using the example Relationships code which works but what I would like to do instead of showing the names of the Pizza shops is just show how many shops the Pizza is available at.

{exp:channel:entries channel="pizzas"}
    <h2>{title}</h2>
    <p>{description}</p>
    <p>{ingredients}</p>
    <h3>Where can I find this pizza?</h3>
    {parents field="specialty_pizzas"}
            <strong>{parents:title}</strong>: <br />
            {parents:phone} <br />
            <p>{parents:address}</p>
    {/parents}

{/exp:channel:entries}

I have tried this, but it does not appear to work, any hints?

{exp:channel:entries channel="pizzas"}
    <h2>{title}</h2>
    <p>{description}</p>
    <p>{ingredients}</p>
    <h3>How many restaurants serve this pizza?</h3>
    {parents field="specialty_pizzas"}
            {parents:speciality_pizzas:total_results}
    {/parents}

{/exp:channel:entries}

1 Answer 1

3

Try this...

{parents field="specialty_pizzas"}
{if parents:count == "1"}{parents:total_results}{/if}
{/parents}
1
  • Does this work if there are other channels that also have the "pizzas" channel as a child? for me, {parents:total_results} is not returning a "filtered" number, it's returning the number of all parent entries. I just posted about it here expressionengine.stackexchange.com/questions/41143/… Mar 11, 2019 at 19:26

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.