0

I'm starting to get the hang of Low Search, but am still running into a bit of confusion.

So, I have my {exp:low_search:form} and {exp:low_search:results} tags up and working fine. When I search, for instance, using keywords, the resulting page has my keyword in the keywords field, and my {exp:low_search:param get="keywords" query="{segment_3}"} tag is outputting the keyword, and my search results are valid.

However, if I create a shortcut for that exact search (created from the search log), my search results work fine, but my form doesn't have the values selected, and my param tag doesn't output anything...

Am I missing something, or is this just not yet a feature of Low Search? If I'm using a shortcut, how can I access the search parameters used so that I can have my field defaults set, and how can I display the params outside of the results tag?

I am using EE 2.9.0 and Low Search 3.2.0.

Thanks!

EDIT: Here is my {exp:low_search:form} tag in it's entirety... My url is like /library/search/helen/. I am seeing the correct search results in my results tag for this shortcut, but cannot set the pre-selected form fields for this search...

{exp:low_search:form
    query="{segment_3}"
    shortcut="{segment_3}"
    result_page="library/search" 
    form_id="search"        
    }
    <fieldset>
        <div class="form-group">
            <label for="keywords" class="the_label">Keywords</label>
            <input type="search" name="keywords" class="form-control" value="{low_search_keywords}" placeholder="Keywords">
            {if low_search_keywords_missing} Please enter keywords{/if}
            <input type="hidden" name="collection[]" value="library_content">
            <input type="hidden" name="loose_ends" value="right">
            <input type="hidden" name="search_mode" value="auto">
        </div> <!-- /.form-group -->

        <div class="form-group">
            <label for="keywords" class="the_label">State / Territory</label>
            <select name="search:library_state_territory" id="option" class="form-control">
              <option value="">-- Select State / Territory --</option>
              {exp:low_options:library_state_territory channel="library_content"}
                {if option:group != ''}<optgroup label="{option:group}">{/if}
                {options}
                  <option value="{option:value}"{if option:value == low_search_search:library_state_territory} selected{/if}>
                    {option:label}
                  </option>
                {/options}
                {if option:group != ''}</optgroup>{/if}
              {/exp:low_options:library_state_territory}
            </select>

        </div> <!-- /.form-group -->

        <div class="form-group">
            <label for="tag-group-2" class="the_label">Type</label><br />
            <select name="tag_name:group2[]" id="tag-group-2" size="5" multiple class="form-control">
              {exp:tag:cloud groups="1" tag_group_id="2"}
                <option value="{tag_name}"{if low_search_tag_name:group2 ~ '/(^|\|)'.tag_name.'($|\|)/'} selected{/if}>
                  {tag}
                </option>
              {/exp:tag:cloud}
            </select>
        </div> <!-- /.form-group -->

        <div class="form-group">
            <label for="date_range" class="the_label">Date range</label>


            <div class="input-daterange input-group" id="datepicker">
                <input type="text" class="input-sm form-control" name="range-from:library_date_published" value="{low_search_range-from:library_date_published}"/>
                <span class="input-group-addon">to</span>
                <input type="text" class="input-sm form-control" name="range-to:library_date_published" value="{low_search_range-to:library_date_published}"/>
            </div>

        </div> <!-- /.form-group -->

        <div class="form-group">



            <label for="tag-group-4" class="the_label">Population Group</label><br />
            <select name="tag_name:group4[]" id="tag-group-4" size="5" multiple class="form-control">
              {exp:tag:cloud groups="1" tag_group_id="4"}
                <option value="{tag_name}"{if low_search_tag_name:group4 ~ '/(^|\|)'.tag_name.'($|\|)/'} selected{/if}>
                  {tag}
                </option>
              {/exp:tag:cloud}
            </select>

        </div> <!-- /.form-group -->



        <button type="submit">Search</button>
    </fieldset>
{/exp:low_search:form}

Also, I have these tags set up to display the currently used search filters... but they don't work with the shortcut either.

<div id="active-search-filters-container" class="clearfix">
    <label class="pull-left">Search Parameters:</label>
    {if '{exp:low_search:param get="keywords" query="{segment_3}" shortcut="{segment_3}"}' != ''}
        <div data-member-id="1" class="search-parameter keyword">
            <button type="button" class="btn btn-default btn-xs">
                <strong>Keyword(s):</strong> {exp:low_search:param get="keywords" query="{segment_3}"}&nbsp;
                {!--<span class="glyphicon glyphicon-remove"></span>--}
            </button>
        </div>
    {/if}
    {if '{exp:low_search:param get="search:library_state_territory" query="{segment_3}" shortcut="{segment_3}"}' != ''}
        <div data-member-id="1" class="search-parameter state">
            <button type="button" class="btn btn-default btn-xs">
                <strong>State:</strong> {exp:low_search:param get="search:library_state_territory" query="{segment_3}"}&nbsp;
                {!--<span class="glyphicon glyphicon-remove"></span>--}
            </button>
        </div>
    {/if}
    {if '{exp:low_search:param get="range-from:library_date_published" query="{segment_3}" shortcut="{segment_3}"}' != ''}
        <div data-member-id="1" class="search-parameter date-range">
            <button type="button" class="btn btn-default btn-xs">
                <strong>Date Range:</strong> {exp:low_search:param get="range-from:library_date_published" query="{segment_3}"}&nbsp;
                {if '{exp:low_search:param get="range-to:library_date_published" query="{segment_3}"}' != ''}
                    - {exp:low_search:param get="range-to:library_date_published" query="{segment_3}"}
                {/if}                       
                {!--<span class="glyphicon glyphicon-remove"></span>--}
            </button>
        </div>
    {/if}
    {if '{exp:low_search:param get="tag_name:group2" query="{segment_3}" shortcut="{segment_3}"}' != ''}
        <div data-member-id="1" class="search-parameter type">
            <button type="button" class="btn btn-default btn-xs">
                <strong>Type:</strong> {exp:low_search:param get="tag_name:group2" query="{segment_3}"}&nbsp;                   
                {!--<span class="glyphicon glyphicon-remove"></span>--}
            </button>
        </div>
    {/if}
    {if '{exp:low_search:param get="tag_name:group4" query="{segment_3}" shortcut="{segment_3}"}' != ''}
        <div data-member-id="1" class="search-parameter pop-group">
            <button type="button" class="btn btn-default btn-xs">
                <strong>Population Group:</strong> {exp:low_search:param get="tag_name:group4" query="{segment_3}"}&nbsp;                   
                {!--<span class="glyphicon glyphicon-remove"></span>--}
            </button>
        </div>
    {/if}
</div> <!-- /#active-search-filters-container -->

1 Answer 1

1

You need to include the parameter shortcut="[shortcut name]" in your {exp:low_search:results} tag. The value can be taken from your url segments.

e.g.

If the url was www.mysite.com/search/bacon and you had a shortcut set up for "bacon" then your search results tag would be

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

You can combine this with the regular query parameter. A site I am currently working on has this:

{exp:low_search:results 
    query="{segment_2}"
    channel="products" 
    limit="18" 
    paginate="bottom" 
    dynamic="no" 
    orderby="title" 
    sort="asc" 
    status="not closed" 
    cache="yes" 
    refresh="120" 
    disable="member_data" 
    require_all="category" 
    shortcut="{segment_2}"
}   

Which might be overkill, but works a treat!

2
  • Hi @foamcow. Thanks, but I am including the shorcut parameter in my {exp:low_search:results} tag. I AM getting the right search results. What I'm not getting is the ability to have my form fields reflect the filters chosen, or the ability to even display what filters are being applied... Sep 24, 2014 at 16:17
  • 1
    Add shortcut="{segment_x}" to the Form tag, too.
    – Low
    Sep 25, 2014 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.