All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Low Search no_results and Stash

Andrew Mac 15 Jul 2012 08:36 problem, complete

Hi Low

I'm really sorry that I can't seem to sort this one out myself ... but I can't!

I have search results code (Low Search) inside Stash content that is then loaded into the site template (partials). The {exp:low_search:results} tag is also inside an {exp:switchee} tag, by the way, but I don't really think that is affecting anything.

Anyway, if the search is successful there is no problem at all, and everything works as expected. If the search returns no results, however, the {if no_results} conditional inside the {exp:low_search:results} tag does not work. The output is completely blank. I have, by the way, tested the search results page as a simple template with nothing but the {exp:low_search:results} tag, and everything works okay.

Unfortunately, I've also got to say that I have done exactly the same thing on another site with Solspace Super Search and it worked exactly as expected. I would much rather go with Low Search on this project, though.

I'm not honestly sure what is going on, or what I should be doing in order to fix the issue. I would really appreciate any advice or hints you might have time to help me with.

Thanks heaps
Andrew

Replies

  1. Low 15 Jul 2012 12:39

    Hi Andrew,

    What happens if you replace the low_search:results tag with a regular channel:entries tag and try to trigger the no_results conditional? Same issue, or does that work as expected?

  2. Andrew Mac 15 Jul 2012 13:17

    Hi Low

    Yes, actually, the same thing does seem to happen. So does that mean that Stash is probably what's causing the issue? I have also posted to the Stash support forum, so I will wait to see what Mark has to say.

    As I mentioned before, I really do want to go with Low Search on this one, even though Super Search works as expected, so I hope Mark can come up with something.

    Cheers
    Andrew

  3. Low 15 Jul 2012 13:31

    Well, the way Low Search handles things, the no_results conditional can be handled by LS itself, when there has been a keyword search that didn't return any results, or by the channel:entries tag itself (which LS calls to display the entries). The first, I could control, the second, not so much. So, addressing the issue from a LS point of view may cause inconsequent behaviour.

    I might have a chat with Mark about it myself to see what the actual issue/conflict is.

  4. Andrew Mac 15 Jul 2012 13:47

    Wow, thanks heaps. That's quite some brains trust, so I'm really confident that if anything can be done, then you two are the guys that can do it!

    Cheers
    Andrew

  5. Low 16 Jul 2012 07:02

    I can see in this thread that Mark has encountered this before. The solution mentioned there -- e.g. Stash either using {if stash_no_results} or LS using {if low_search_no_results} instead -- would be workable.

    I'll see if I can add that to LS.

  6. Andrew Mac 16 Jul 2012 07:30

    Hi Low

    Once again, thanks so much for quick and thorough work you do with your add-ons. It's one of the reasons I'm planning to go with Low Search!

    My feeling (based on my limited understanding of the problem, of course) is that I'd probably be happier if you could add the low_search_no_results conditional. The reason for this is that all templates in the site are fed through a single Stash-driven wrapper, and I'd much rather have the logic for the no_results tag in the search template rather than the wrapper template. But as I said, it's not my area of expertise, so I am happy to leave it to you to decide on the implementation you feel will best suit your product ... if you do get time to do anything about it, naturally :-)

    Cheers
    Andrew

  7. Low 16 Jul 2012 10:18

    I managed to get a fix in, so next version will have support for low_search_no_results. If you need it now, send me an email, and I'll send you the patched version.

  8. Andrew Mac 16 Jul 2012 12:18

    Brilliant. Absolutely brilliant, and thanks so much.
    The email is on it's way. You, sir, are a genius :-)

    Cheers
    Andrew

  9. Heiko 17 Jul 2012 09:20

    {if low_search_no_results} works! Best support ever!! :)

  10. trif3cta 24 Aug 2012 16:58

    Thank you, just ran into this!

  11. ZenBug 26 Jul 2016 16:38

    I'm having this same problem, but I'm already using the {if low_search_no_results} conditional.

    If I leave the keyword field blank, the search results show everything instead of doing what's in the conditional. If I enter a valid query, the search works fine.

    I've also tried taking Stash out of the equation:

     
    {exp:low_search:results query="{segment_3}" limit="50" channel="mychannel" keywords:loose="right" keywords:mode="all" require_query="yes"}
    {title}
    {if low_search_no_results}
    No Low Search results
    {/if}
    {/exp:low_search:results}


    Am I doing something wrong?

    Low 26 Jul 2016 20:26

    Not sure what you mean here. Can you perhaps start a new thread and provide more info like PHP, EE and LS versions, full template details and template debugger info? thanks.

    ZenBug 26 Jul 2016 20:34

    Sure, but just before I do all that, let me clarify my question:

    If I add require_query="yes" to the Low Search results tag, and then a visitor hits the search button without typing a keyword, should the no_results conditional be triggered?

    Low 26 Jul 2016 20:38

    Depends. If you've set require_query="yes" and you're using encoded queries, then the segment you're passing to the Results tag shouldn't be empty. If you're not encoding queries, there need to be GET queries in the URL; otherwise no_results is triggered.