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.

{if no_results} condition writing elements to page when false?

June 21, 2007 1:47pm

Subscribe [2]
  • #1 / Jun 21, 2007 1:47pm

    hothousegraphix

    851 posts

    I have a condition in my page that displays weblog results for any situation
    where results may not exist. I’m using the {if no_results} tag.

    What I’ve discovered is that when I have results, or when if no_results is false, the
    container elements (my divs) within these tags are writing to my page. No content is, just the divs.

    This is causing layout issues for me. The styles associated with these div are being applied to the empty div and creating a large about of negative space.

    Is there another tag that will achieve what I want but prevent the container div from writing to my pages?

    Thanks.

  • #2 / Jun 21, 2007 1:49pm

    Derek Jones

    7561 posts

    Can you post the full template code?  Nothing inside {if no_results}{/if} should be rendering unless there are, well, no results.  It sounds like you might be nesting tags, so showing us the template code will be helpful.

  • #3 / Jun 21, 2007 1:53pm

    hothousegraphix

    851 posts

    Sure

  • #4 / Jun 21, 2007 1:59pm

    hothousegraphix

    851 posts

    I’m trying to paste my template but the system is not letting the entire template paste (too many characters).

    So I’ve attached a txt file.

  • #5 / Jun 21, 2007 2:23pm

    Derek Jones

    7561 posts

    Ok, though I’m not seeing it.  Can you tell me precisely which markup from the if no_results conditional is being output, and perhaps a link to the page where it’s occurring?

  • #6 / Jun 21, 2007 2:42pm

    hothousegraphix

    851 posts

    Sure…

    page

    The divs with the id’s “addEventHead_rt” and “clearer” are the offending elements.

    When looking at the layout, the excess space below each “more” hyperlink is being caused by the top margin property associated with div “addEventHead_rt” because the it is present.

  • #7 / Jun 21, 2007 2:47pm

    Derek Jones

    7561 posts

    That’s not coming from your no_results conditional.  Look up.

    <div id="addEventHead_rt">
     {date_heading display="monthly"}
             <h2 class="month">{entry_date format="%F"}</h2>{/date_heading}
             {date_heading display="yearly"}
             <h1 align="right">{entry_date format="%Y"}</h1>
             <div class="pagination">{exp:weblog:calendar switch="calendarToday|calendarCell" weblog="events_entry" show_future_entries="yes"}
                     <span><a href="http://{previous_path=Test/Events/}">Previous Month</a>  |  <a href="http://{next_path=Test/Events/}">Next Month</a></span>{/exp:weblog:calendar}
             </div>{/date_heading}
     </div><div class="clearer"> </div>
  • #8 / Jun 21, 2007 2:55pm

    hothousegraphix

    851 posts

    I actually just realized that my id’s should be classes because these elements are repeating in my page.

    You have only located the first set of those div’s which in fact are writing to my page as intended.

    If you scroll down further in the document, you will notice that I am repeating that section.

    Could this be because I incorrectly applied an ID to repeating elements?

    I’m updating to classes now to test.

  • #9 / Jun 21, 2007 2:57pm

    Derek Jones

    7561 posts

    Look at the format and whitespacing, hothousegraphix.  It is definitely from the markup I copied above.  If it were from the no_results, the other tags would show up too.  And no, EE does not examine or modify your HTML.  It doesn’t care if you use classes, ID’s, or that you are using HTML tags at all.

    Neither of those Date Heading tag pairs are rendering anything at that URL, leaving you with:

    <div id="addEventHead_rt">
    
    
    
    
    
    
    
    </div><div class="clearer"> </div>
  • #10 / Jun 21, 2007 3:19pm

    hothousegraphix

    851 posts

    AHHHH. I now see why this is occurring. So I’d be better off wrapping the div in the date tags as such:

    {date_heading display="monthly"}
    <div class="addEventHead_rt">
    <h2 class="month">{entry_date format="%F"}</h2>{/date_heading}
    {date_heading display="yearly"}
    <h1 align="right">{entry_date format="%Y"}</h1>
    <div class="pagination">{exp:weblog:calendar switch="calendarToday|calendarCell" weblog="events_entry" show_future_entries="yes"}
    <span><a href="http://{previous_path=Test/Events/}">Previous Month</a>  |  <a href="http://{next_path=Test/Events/}">Next Month</a></span>{/exp:weblog:calendar}
    </div>
    </div>
    <div class="clearer"> </div>
    {/date_heading}

    since all entries fall within a single month, the {date_heading display="monthly"} only appears once and because my div sat outside the date tags each iteration through wrote them to my page.

    Thank you for the clarification, I appreciate it.

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

ExpressionEngine News!

#eecms, #events, #releases