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.

Only showing heading once in loop

June 14, 2013 10:31am

Subscribe [2]
  • #1 / Jun 14, 2013 10:31am

    I’d rather not have anything show if there aren’t any results. Right now, it just shows the “Blogs by” text and “No Results”. I’d rather not show any of that if there aren’t results. Is there a way to not show the h3 if there are no results? Obviously I can’t have it in the tag pair because it’ll keep looping over and over.
    Also, this is just the snippet of my related channel entry…

    {exp:channel:entries channel="profile"}
    <h3 class="sub">Blogs by {first_name} {last_name}.</h3>
    {parents channel="blog" field="blogger" status="Featured Blogger|open"}
    {if parents:no_results}No Results.{/if}
    <a href="http://{site_url}site/blog_view/{parents:url_title}">{parents:title}</a>
    {/parents}
  • #2 / Jun 17, 2013 1:34am

    travisb

    172 posts

    Try moving your h3 text to within your relationship loop:

    {exp:channel:entries channel="profile"}
     
     {parents channel="blog" field="blogger" status="Featured Blogger|open"}
      {if parents:no_results}No Results.{/if}
      
      {if parents:count == 1}
       <h3 class="sub">Blogs by {first_name} {last_name}.</h3>
      {/if}
      
      <a href="http://{site_url}site/blog_view/{parents:url_title}">{parents:title}</a>
     {/parents}
  • #3 / Jun 17, 2013 11:16am

    I never thought of doing it that way, that opens up more possibilities w/ EE for me! Thanks that worked great!

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

ExpressionEngine News!

#eecms, #events, #releases