ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Workaround for nesting related entries

December 17, 2012 5:50pm

Subscribe [2]
  • #1 / Dec 17, 2012 5:50pm

    jsuissa

    147 posts

    We tried to construct the following piece of code and the nesting of related entries failed.

    The goal is to add an “s” to “Practice Leader” only if practice_leader_2 exists. We’ve tried a few other approaches and they all don’t seem to be supported.

    In a case like this is there some other way to evaluate the condition?

    Thanks in advance for any input.

    {related_entries id="practice_leader"}
       <div class="p-leader-title">Practice Leader{related_entries id="practice_leader"}{if no_related_entries}{/if}s{/related_entries}</div>
           {if no_related_entries}
            <div class="p-leader-title">Practice Professionals</div>
            <div class="p-leader-detail"><a href="http://{path=ourpeople/practicearea/{segment_2}}">View professionals associated with_this practice area</a></div>
           {/if}
    
           <div class="p-leader-detail"><a href="http://{path=ourpeople/bio/{url_title}}">{people_name}</a>
           <span>{people_title}</span>{embed="includes/phone" entry_id="{entry_id}"}
    <a href="mailto:{people_email}">{people_email}</a>
           
    {/related_entries}
  • #2 / Dec 18, 2012 8:38am

    Matt:P

    277 posts

    Hi there

    The {related_entries} tag is only able to render a single entry. Michael explains it well at the bottom of this page: http://ellislab.com/expressionengine/user-guide/modules/channel/relationships.html#related-entries-tag-pair

    A better route may be to use the {reverse_related_entries} tag which will allow you to look up and display multiple relationships.

    You could then use:

    {if count > 1}s{/if}

    Let us know if that helps

    Matt

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases