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.

Don't display headers when no items are found in a reverse_related_entries

May 26, 2011 7:46am

Subscribe [3]
  • #1 / May 26, 2011 7:46am

    R Gruyters

    14 posts

    Hi ya,

    I’m using the following code to show category relations with an article:

    <div class="pf-related">
        <h4>U vindt meer van deze klant in</h4>
    <p>    <ul class="fancy"><br />
        {exp:channel:entries channel="client" disable="member_data|pagination" status="open" entry_id="{embed:rel_id}"}<br />
            {reverse_related_entries}<br />
                {categories show="not {segment_3_category_id}"}<br />
            <li><span class="icon">»</span> <a href="http://{path=portfolio}">{category_name}</a></li><br />
                {/categories}<br />
            {/reverse_related_entries}<br />
        {/exp:channel:entries}<br />
        </ul><br />
    </div>

    What I want todo is don’t show the “pf-related” div (and its children) when there is no relational categories found.

    I have tried with “if no_reverse_related_entries” and “if no_results”, but that didn’t work.

    Is there a way to do this? Or should i rewrite my code?

    Regards,

    Robin

  • #2 / May 26, 2011 11:57am

    Sue Crocker

    26054 posts

    Hi, Robin.

    Have you seen: http://ellislab.com/expressionengine/user-guide/modules/channel/reverse_related_entries.html

    {reverse_related_entries sort="desc" orderby="title"}
     {if no_reverse_related_entries}
      <h2>No Events for This Performer</h2>
    <p> {/if}<br /></p><h2>{title}</h2>
    <p> {body}<br />
    {/reverse_related_entries}

  • #3 / May 31, 2011 6:57am

    R Gruyters

    14 posts

    That doesn’t work for me. It still displays an empty unordered list.

  • #4 / Jun 01, 2011 6:16am

    John Henry Donovan

    12339 posts

    Robin,

    Can you explain what you mean by and ‘empty’ unordered list? Do you mean the mark-up renders?

    Can you test this outside of an embed please?

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

ExpressionEngine News!

#eecms, #events, #releases