5

Is there a way to get the total number of items chosen in a multiple relationships field?

  • 3
    Grrr EE Docs are missing, and inconsistent! – Bradley Flood Aug 11 '14 at 5:55
9

Did you try this tag:

{relationship_field:total_results}

Example:

{exp:channel:entries channel="xyz"}
        {relationship_field}
           {relationship_field:total_results}
        {/relationship_field}
{/exp:channel:entries}
  • Yup. That is what I need. – arvinsim Sep 9 '13 at 6:15
3

In addition to Bhashkar Yadav's answer, this worked successfully for me:

{exp:channel:entries channel='channel_xyz' status='not closed'}
    {if relationship_field:total_results > 0}
        ...do something!
    {/if}
{/exp:channel:entries}

...that is, having it outside of the relationship field loop.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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