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}

3

Try this...

{parents field="specialty_pizzas"}
{if parents:count == "1"}{parents:total_results}{/if}
{/parents}
| improve this answer | |
  • 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/… – Mike Lohrman Mar 11 '19 at 19:26

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.