Using Low Search keywords to perform a tag search parameter in a Grid/Matrix column
Hi Low,
I've got a 'blog' channel with a body field and a Grid/Matrix field that has two columns: a file field for an image, and a text field for entering keywords that describe te image, specifically for search. What I'm hoping to do is create two types of searches for users: a standard entries search using weighting on the title and body text (Low Search collection 1) and zero weight on the Grid/Matrix, and an image search by applying full weight on the the Grid/Matrix field (Low Search collection 2).
That seems pretty straightforward to set up, no issues there.
The results page for the body/title search is also easily doable, but it's the results page for the image where thing are getting unclear. I could simply display the entries that match the search, showing all the Grid's images of these entries. The thing is, what I'm trying to do is to show only the images that correspond with the search (making it truly an image search, not so much an entries search).
The way I understand it, I could use a search:column_name="" template tag parameter on the Grid/Matrix tag pair, and filter and display the matched images. However, in order for that to work I need to have the search words in a specific format so as to comply with EE's formatting as stated on http://ellislab.com/expressionengine/.... The problem is that from what I understand, the only variable I can work with is {low_search_keywords}, with the keywords simply separated with spaces.
Do you know of a way to make this work with Low Search? Perhaps using Low Replace to replace the spaces with pipes symbols or ampersands? Am I overcomplicating this or trying to create something unfeasable?
Replies
Low 3 Sep 2013 07:39
Biggest issue here is parse order. In the Results tag, all variables are parsed in one go. This includes the {low_search_keywords} var and the Matrix/Grid field vars. You'd need to have the keywords before you get to the Results.
One way of doing this is using an embed. If there is a search, use the keywords tag to pass on the keywords as an embed var.
Then use {embed:keywords} in the search/the_results template as input for the search:column_name="" parameter.
You could even (like you suggested) use Low Replace around the low_search:keywords tag to replace spaces with pipes.
JolledeWit 3 Sep 2013 16:05
Great, parse order... ;) I'm gonna see if I can figure out how to implement your solution, perhaps utilising Stash parsing.
Thanks, Low!