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

Support archive

low_search_keywords not working

ivyone 10 Sep 2012 18:49 problem, active

Hi Low,

quick question. Why doesn't this work?

 
{exp:low_search:results query="{segment_2}" limit="10"}

{if count == 1}<ul>{/if}

<li>
<h2><a href="{page_url}">{title}</a></h2>
<p>{low_search_excerpt}</p>
<p><a href="{page_url}">Lees meer</a></p>
</li>

{if count == total_results}</ul>{/if}

{if no_results}
<p>Geen resultaten gevonden</p>
{if low_search_keywords}
{embed="_embed/search_suggest" zoekwoord="{low_search_keywords}"}
{/if}
{/if}
{/exp:low_search:results}


Outside of the exp:low_search:results the following code works like a charm.
 
{embed="_embed/search_suggest" zoekwoord="{exp:low_search:keywords query='{segment_2}'}"}


Problem is, i only want to show alternative spelling suggestions if there are no search results.

Have an idea about this?

Replies

  1. Low 10 Sep 2012 19:38

    The no_results template chunk is prepared before anything else. If you want to display keywords there, use the {exp:low_search:keywords} tag.

  2. ivyone 10 Sep 2012 20:02

    I understand, but does this mean that i can't embed the keywords used in the search ONLY in case there are NO search results?

  3. Low 10 Sep 2012 20:04

    You can use the {exp:low_search:keywords} tag inside the Results tag just fine.

  4. ivyone 10 Sep 2012 20:19

    Hi Low,

    sorry but i can't seem to get it working. Some code examples.

    Outside exp:low_search:results the following works like a charm.

     
    <p>{embed="_embed/search_suggest" zoekwoord="{exp:low_search:keywords query='{segment_2}'}"}</p>


     
    {exp:low_search:results query="{segment_2}" limit="10" paginate="bottom" }
    {embed="_embed/search_suggest" zoekwoord="{low_search_keywords}"}
    {/exp:low_search:results}


    AND

     
    {exp:low_search:results query="{segment_2}" limit="10" paginate="bottom" }
    {embed="_embed/search_suggest" zoekwoord="{exp:low_search:keywords query='{segment_2}'}"}
    {/exp:low_search:results}


    produce nothing.

    Im i doing something wrong? If i can do something like

     
    {exp:low_search:results query="{segment_2}" limit="10" paginate="bottom" }
    {embed="_embed/search_suggest" zoekwoord="{exp:low_search:keywords query='{segment_2}'}" number_results="{absolute_results}"}
    {/exp:low_search:results}


    then i could make the embed trigger only when the number_results == '0'.

  5. Low 10 Sep 2012 20:25

    If there are 0 results, the chunk between the {if no_results} is returned. You can't really use regular variables in that chunk, but you can use tags. So, something like this should work:

    {exp:low_search:results query="{segment_2}"} 
    {if no_results}
    {embed="_embed/search_suggest" zoekwoord="{exp:low_search:keywords query='{segment_2}'}"}
    {/if}
    {/exp:low_search:results}