I am trying to filter and sort search results in Adobe Business catalyst.
So how can I capture the user inputted keyword(s) with liquid and then look through the products and show the relevant results.
I am trying to filter and sort search results in Adobe Business catalyst.
So how can I capture the user inputted keyword(s) with liquid and then look through the products and show the relevant results.
It depends. If you want to capture the users search in Liquid as they type, then the answer is no. (Use JS for that.) But you can us some JS to appeand the search query into the URL. When the user clicks search, it takes them to the search results page with the URL paramater you can then read the URL paramater using liquid and run some logic based upon that.
For example, let's say the URL, with the URL paramater, is this: examples.com/search-results?search=tshirt
You can then run this logic:
{% if globals.get.search contains 'tshirt' -%}
<!-- Do something or show something. -->
{% else -%}
No items with the word globals.get.search were found.
{% endif -%}
The word search in globals.get.search
would be the URL paramater. Also, if you want to catch multiple words with the statement, us the or
operator. IE:
{% if globals.get.search contains 'tshirt' or globals.get.search contains 't-shirt' -%}
Hopefully, this can point you in the right direction.
You cannot capture user input with Liquid in Adobe Business Catalyst.
Liquid runs when the page is loaded or reloaded. You can't use it in the same way that you would use Javascript to capture data being dynamically entered onto the page by a user.
Is there a reason you don't want to use the Product Search Form (insert-able in the page editor: Toolbox > ECommerce > Products > Product Search Form) and {module_productresults} combo?
Here's an instructional on setting up and customizing product search.