Can a hidden field be used with piped entry IDs for a directed search?
Hi Low - I'm wondering if the low_search:form tag can use a piped set of IDs as a keyword search to allow me to use low_search to perform a compare function? I can handle everything on the results screen for the actual comparison, as long as there is a way for the search form to accept a series of IDs and therein limit the results to those entries. Or is that a filter function and not a search function?
Replies
Low 9 Nov 2015 21:55
I'm not sure what you mean.
But if you add a hidden input field to the form like this:
...then you can get to that value in the Results tag like this:
Low 9 Nov 2015 21:56
And if you want to limit the results by any given id, you can use the entry_id param instead.
QB Marketing 10 Nov 2015 20:05
Thanks Low. I did get it working using basically this:
{exp:low_search:form result_page="catalog/compare" entry_id="[]"}
Compare
{/exp:low_search:form}
And my plan is to use javascript to select checkbox clicks in the long list of products below the form to populate the value with piped IDs on the hidden field.
One follow-up question - on the results page, i need to do a conditional lookup of which immediate parent category the products are coming from so I can display different sets of custom fields. The catalog itself displays with category url segments right up to and including single product display (catalog/category/first_parent/first_child/product_url_title) so I'm wondering if I should handle it that way on the search results template (I'm hoping to run the conditional on the category_url_title rather than the ID just so it's easier to tell them apart in the template). But if the encoded query is always the last segment, how can I use the second last segment for the conditional? There is no "second last segment" global variable in EE. Would I have to accomplish this with regex? Or is there another way i can run category-based conditionals inside the search results (every product is assigned only to a single category, and all products being "compared" will be coming from the same category)?
So inside the search results tag pair, i need to do something like:
{if parent_category == "widgets"}
Length: {length}
Width: {width}
{if:elseif parent_category == "butter"}
Height: {height}
Weight: {weight}
{if:else}
{/if}
Is there a direct way to access the category dynamically within the search results as opposed to having to find a way to get the categories into the URL and using a segment conditional?
Low 12 Nov 2015 20:44
Note that using the entry_id param in the Form tag won't actually do anything.
You might be able to use Mo Variables to target the segment you want: https://devot-ee.com/add-ons/mo-varia...
As for accessing the categories; since the Results tag extends the channel:entries tag, you can target categories in the same way you would with the channel:entries tag. That probably means you'll have to use the {categories} variable pair.