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

Support archive

Low Search keywords still being logged, even though it's inside of a conditional.

john.e.peacock 22 Apr 2013 15:42 question, complete

I have a conditional check to see if keywords have been passed via $_GET into the search results page.

{if {exp:stash:not_empty name="search_keywords"}}
All Results for "{exp:stash:get name="search_keywords"}"
{exp:low_search:results collection="somecollection" log_search="yes" exact="false" keywords="{exp:stash:get name="search_keywords"}" limit="20" loose_ends="yes" parse="inward"}
{/if}

This works fine for showing results if a search was performed, and if it wasn't, everything inside of the main conditional tag is hidden as expected. The only indication that there's a parsing problem is that the search log fills up with {get:keywords}, so the plugin looks like it's processing even though it's inside of a conditional.

Any ideas as to how to solve this?

Replies

  1. Low 22 Apr 2013 15:48

    Parse order. The conditional is an advanced one and will be parsed after the tags are parsed, so the Results tag will get executed whether there are keywords or not. It will just get removed after the fact. Not much Low Search can do about that.

    I'd suggest taking another look at how you check for keywords. Maybe use Switchee or IfElse to avoid the advanced conditional.

  2. Low 22 Apr 2013 15:48

    Oh, and exact="false" won't do anything, so you can remove that from the template.

  3. john.e.peacock 22 Apr 2013 16:25

    Thanks, I had assumed that the conditional I used to grab {get:keywords} was a simple one that happened early in the parse order but was wrong. Ended up using ifElse with parse='inward' and it worked like a charm. Thanks!

  4. Jared Wohlgemuth 10 Aug 2013 18:31

    I think I have a similar goal, searching for either a student name or a school name in a Low Search.

    The first < li > works when finding a student name, and the second < li > works when finding a school name. What's the correct conditional to have one or the other search take place?

    <li>{title} -
    <a href="{path='schools/school-details/{student_schoolname:entry_id}'}">{student_schoolname:title}</a>
    </li>

    <li>{title} -
    <a href="{path='schools/school-details/{entry_id}'}">{title}</a>
    </li>

  5. Low 10 Aug 2013 20:27

    Well, that depends. Are the two in different channels? Then you could simply use

    {if channel_id == "1"} ...the first option... {/if} 
    {if channel_id == "2"} ...the second option... {/if}


    Basically anything you could do in the channel:entries tag, you can use in the Results tag.