0

I have a primary exp:low_search:results loop which the user can filter using low search form. The form updates the URL using normal query strings. So /index?foo=bar displays matches where field foo is equal to bar.

Simultaneously, I have a Count in the header which tallies all matches from that same channel with a certain special criteria:

{exp:low_search:results channel="my_channel" status="special_status"}{if count == 1}{total_results}{/if}{/exp:low_search:results}

My issue is that when we pass "?foo=bar" in the URL, there is no way to avoid having it affect the count query as well. So the count is incorrect on results pages for this channel.

We also have a global search page using a "keywords=foo" query parameter, and it affects the count query too. Is there a way we can tell the count query to ignore parameters in the URL, or must we re-write the count query?

Thanks!

2 Answers 2

0

If you're using GET variables (ie. not encoding the query), then there's currently no way to ignore the search params; they will always be applied. If you must ignore them, use encoded queries and omit the query="" parameter.

As a sidenote: use {absolute_results} when paginating results to get the correct result count.

2
  • Thanks, this makes sense, and appreciate the tip for absolute_results. I think I see a strategy with a custom low search filter that is last in the parse order, which ignores the entry_ids that are passed to it and just does a raw count, or perhaps something with exp:query. I’ll reply back here with what I come up with for future reference. Aug 21, 2015 at 14:13
  • You could also create an extension using the low_search_pre_search hook and optionally empty out the parameters with ee()->low_search_params->reset();.
    – Low
    Aug 21, 2015 at 16:11
0

Are you looking for the total posts in the channel, as opposed to the total search results in the channel?

If so use a standard channel:entries tag to get your total, then use the search results tag for the results?

3
  • For both tags, we apply several filters, including a custom Low Search filter. Sorry, should have been more clear about that. Beginning of Primary Loop: {exp:low_search:results channel="my_channel"} (With several parameters applied via the url) Beginning of Count loop: {exp:low_search_results channel="my_channel" params="special_param"} (Want to ignore query params) Aug 20, 2015 at 12:46
  • Hi Ty, so yea i I understand wouldn't my idea be relivent? instead of trying to count the results of the search, minus the filters applied to the search, you would count the entries in a channel:entries loop, not the search results loop. Can you provide a more in depth template example? Or even an idea on the 'special_params'??
    – Blatant
    Aug 20, 2015 at 13:03
  • Hey, the reason is that the special param is a custom low search param we wrote which filters based on special criteria – we cannot replicate the same loop using exp:channel:entries. Thank you though. Aug 21, 2015 at 14:10

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.