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

Support archive

Low Search Shortcut Name

Micah Kohne 18 Jun 2018 22:50 question, complete

Hello - is there a way to extract the {low_search_shortcut_name} from the encoded search query after a result has been filtered?

For example, I have a set of search results that I want to then filter by using a shortcut. I'm filtering the results using {low_search:url shortcut="type1"}. This works, it filters the results as needed. But now I want to be able to add a heading to the page labeled "Type 1".

Does this make sense?

Replies

  1. Low 19 Jun 2018 06:50

    You should be able to use {low_search_shortcut_id}, {low_search_shortcut_label} and {low_search_shortcut_name} in the Results, Form and Filters tag, provided a shortcut was given in the tag's shortcut parameter.

    If an encoded query is, coincidently, the same as a shortcut, then that data isn't available.

  2. Micah Kohne 19 Jun 2018 13:36

    Actually, I misspoke - my filter wasn't working correctly. This is how my filter is currently set up:

    {exp:low_search:filters query="{segment_3}"}
    <ul>
    <li><a href="{low_search:url shortcut="type1"}">Type 1</li>
    <li><a href="{low_search:url shortcut="type2"}">Type 2</li>
    </ul>
    {/exp:low_search:filters}


    Can I use the shortcuts in the filter like this?

  3. Low 19 Jun 2018 13:50

    You can try and pass through the shortcut name rather than the query it generates, eg.

    <a href="{path='search/type1'}">Type 1</a>


    And then use something like this in the Results tag:

    {exp:low_search:results query="{segment_2}" shortcut="{segment_2}" ...}


    That way, if a valid shortcut is found, it will use that. Otherwise, it will treat the second segment as an encoded query.

  4. Micah Kohne 19 Jun 2018 14:00

    Thanks - that doesn't seem to filter the search results. I'm trying to filter the results by type (shortcut) once the search has already been done.

    I can do this by category using the filter tag, but really trying to get that shortcut named pulled once filtered.

  5. Low 19 Jun 2018 14:19

    The shortcut data is only available if the shortcut="" param is set on the Results tag, containing a valid shortcut_name value.

    The way you're using it now, by making shortcut part of the encoded query, LS will think it's a parameter part of some filter.

    So, you either use a shortcut to filter entries by passing a string to the shortcut="" param, or you filter entries by encoded query using the query="" parameter. One will overwrite the other, depending on the force_x parameter set, see https://gotolow.com/addons/low-search...

    The shortcut name cannot be part of the encoded query, but should be as is, usually readable in the URI.

  6. Micah Kohne 19 Jun 2018 15:41

    Okay - makes sense, thanks for the help.

  7. Micah Kohne 19 Jun 2018 18:04

    I was able to get what I needed by adding a conditional statement to pull the category parameter values:


    {if low_search_category == '36'}Type 1
    {if:elseif low_search_category == '22'}Type 2
    {if:elseif low_search_category == '15'}Type 3
    {if:elseif low_search_category == '13'}Type 4
    {if:else}Filter Results{/if}


    Appreciate the help.