low_search_keywords not working
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
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.
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?
Low 10 Sep 2012 20:04
You can use the {exp:low_search:keywords} tag inside the Results tag just fine.
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.
AND
produce nothing.
Im i doing something wrong? If i can do something like
then i could make the embed trigger only when the number_results == '0'.
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: