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

Support archive

Possible to output the field values that were searched for?

Stephen 13 Aug 2012 23:04 question, complete

Hi Low,

I've currently got about 1,000 categories in 4 category groups, and just over 3,500 entries. I've been using the Gwcode Categories plugin to output the categories into the drop down menus in my Low Search form using the following code:


<label>Town</label>
<select name="category[]">
<option value="">All towns</option>
{exp:gwcode_categories group_id="4" show_empty="no" style="linear" orderby="cat_name" sort="asc"}
<option value="{cat_id}"{if cat_id IN ({low_search_category})} selected="selected"{/if}>
{cat_name}
</option>
{/exp:gwcode_categories}
</select>


The problem is that I'm finding the performance in outputting all these categories to be quite slow, so I'm going to have to cache the Gwcode Categories results using CE Cache.

However, if I cache these, then my conditionals to show the selected drop down option in my Low Search form will no longer work: {if cat_id IN ({low_search_category})} selected="selected"{/if}

I think I'll be able to set the selected drop downs via JS instead, but to do that, I need to be able to output the field values that were searched for in some hidden fields within the results tag.

Is it possible to do this at all? I've looked through the docs but don't think so, but thought I'd post here in case I'm missing anything.

Besides my strange use case above, I guess some people might want to output what was was searched for in the same way that you can output the keyword that was searched for.

Thanks,

Stephen

Replies

  1. Low 14 Aug 2012 10:38

    The variable {low_search_categories} will output a pipe-separated list of all selected categories. You could use that in your JS to determine which categories were selected. Perhaps use something like

    var cat_id = '{low_search_categories}'.split('|');


    ...to get an array of selected categories in JS.

  2. James Flynn 25 Nov 2012 19:14

    I am working on something to this now and also was using gwcode categories. I am running into the same issue (all searches are category filtering based through a huge number of entries). I already have a way to set check the checkboxes using js. But how would you go about caching this? I was looking at the possibility of using stash to cache each of the search pages. I see reference in the stash's source that mentions low search support and it looks like it looks for the encrypted search string but could not find any documentation about it. Have either of you worked with that before or have any advice on caching each search options (category selections) page or if there is a different possible way to go about this to optimize.

    Thanks,
    James