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.

Weird If No Results

June 10, 2010 7:34am

Subscribe [4]
  • #1 / Jun 10, 2010 7:34am

    BC Team

    244 posts

    If no results tag is only working if I put a set of empty tags in front like this:

    {if no_results}{/if}
    {if no_results}
        //Some HTML here
    {/if}

    This is occurring inside a query and also in comments tags.

    (EE 1.6.8 - Build:  20100415)

  • #2 / Jun 10, 2010 11:05am

    Sue Crocker

    26054 posts

    I can replicate this behavior in 1.6.9 build 20100430.

    Can you please post this to the EE 1.x BugList with a link to this post, and respond back here with a link to the bug report?

  • #3 / Jun 10, 2010 11:20am

    BC Team

    244 posts

    I just submitted to the BugList as requested:

    https://support.ellislab.com/bugs/detail/12739/

    The details that I entered aren’t showing up in the bug list.

  • #4 / Jun 10, 2010 11:28am

    Sue Crocker

    26054 posts

    I fixed that part, you’re use of the curly brace caused the text not to show. Thanks for reporting this.

  • #5 / Jun 10, 2010 11:34am

    BC Team

    244 posts

    I don’t know how you replicated but I now think I have this problem actually:
    http://expressionengine.com/docs/modules/query/index.html#3800

    I think maybe the way I have nested the tags:

    {exp:weblog:entries}
    {ff_matrix}
         {exp:query}
              {if no_results}{/if}
              {if no_results}
                //HTML FOR NO RESULTS
              {/if}
              {/exp:query}
    {/ff_matrix}
    {/exp:weblog:entries}
  • #6 / Jun 10, 2010 11:39am

    BC Team

    244 posts

    This seems to work, so even though I don’t care about finding no entries it means the other tags now work.

    {exp:weblog:entries}
    {if no_results}{/if} <-- THIS BIT
    {ff_matrix}
         {exp:query}
              {if no_results}
                //HTML FOR NO RESULTS
              {/if}
         {/exp:query}
    {/ff_matrix}
    {ff_matrix}
         {exp:query}
              {if no_results}
                //HTML FOR NO RESULTS
              {/if}
         {/exp:query}
    {/ff_matrix}
    
    {exp:comments}
         {if no_results}
           //HTML FOR NO RESULTS
         {/if}
    {/exp:comments}
    
    {/exp:weblog:entries}
  • #7 / Jun 10, 2010 5:23pm

    Ingmar

    29245 posts

    I am glad you found a workaround for now.

  • #8 / Jul 07, 2010 3:51pm

    Robin Sowell

    13255 posts

    K- I’m not replicating in a quick test:

    {exp:query sql="SELECT title from exp_weblog_titles where entry_id = '111111111111'"}
    {title}
    
    {if no_results}
    Nada for you!
    {/if}
    
    {/exp:query}

    I get the expected ‘Nada for you!’.

    Now expect to have a problem if you’re nesting tags- because the no_results may get confusing with regard as to WHICH tag it has no results for.  In the above- well, I try REALLY HARD not to nest a query inside a weblog tag unless I know for sure I’m only getting one results- because it’s going to loop and do a query for each result.  And that’s w/out tossing matrix into the mix.  Be sure you’re not generating hundreds of queries w/out realizing it.

    And that said- if you want them parsed independently- you’d want to move the query to another template- embed that template- pass the variables as embed variables- and then they’ll be processed independently.  But yes- that no_results is for the weblog tag.

    Also- it’s a bad idea to nest the comment tags inside the weblog tag- you can get variable conflicts and it’s just not to be used that way.

    All that aside- are you folks replicating an issue w/out nesting your tags?

  • #9 / Jul 07, 2010 9:08pm

    BC Team

    244 posts

    It was the nesting. Putting a no_results tag outside the query tag it worked.

    Oops, will take the comments out of the weblog tags.

  • #10 / Jul 08, 2010 12:50am

    John Henry Donovan

    12339 posts

    BC Team,

    Has Robin answered all your questions or do you have any outstanding?

  • #11 / Jul 08, 2010 12:53am

    BC Team

    244 posts

    Yes all fixed.

  • #12 / Jul 08, 2010 1:06am

    John Henry Donovan

    12339 posts

    Great stuff! Feel free to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases