Low Search to filter Entries by a Text Input field
We are trying to use Low Search to filter articles by author.
Articles is the channel, author is a text input field within the entry. We would like to display the article and include the authors name at the top which links to a filtered list of all other articles by that author.
We are having trouble generating the link to the filtered list of entries. Any help or tips on how to execute this are much appreciated.
Replies
Low 8 Jan 2016 08:43
You can use the URL tag to generate a link to search results. Since you're targeting a specific field, your best option is to use the Field Search filter to get the results you want.
Optionally, you can add exact="search:author_field" to your results tag so the name given must exactly match the content of the field.
author_field is the name of the field in which you store the author name.
Digital Designs 8 Jan 2016 17:09
Ok, this makes sense except can we dynamically populate the search according to what article is being viewed? I havent been able to get the following code to work:
<a href="{exp:low_search:url result_page="search/results" search:article-author="{article-author}"}">
Where we would like to populate the search with the current author of the article being read. Does this make sense?
Low 9 Jan 2016 09:22
Yep, that would work.
Digital Designs 13 Jan 2016 16:20
Ok, we got this working while searching one field. We would like to display articles and photos (separate channels) posted by the same author. How could we do this? The "author_field" is named something different for each channel, can we search multiple fields across channels and generate a url that would display all content by this particular author?
Thanks for your help!
Low 13 Jan 2016 16:31
If you're using multiple search:field parameters that target different channels, make sure you add smart_field_search="yes". See http://gotolow.com/addons/low-search/...
Digital Designs 13 Jan 2016 16:46
Ok we will add that parameter. Could you give an example of what the code would look like to search more than one field? Would it be something like this:
<a href="{exp:low_search:url smart_field_search="yes" result_page="search/results" search:article-author="{article-author}" search:photo-source="{photo-source}"}">
Low 13 Jan 2016 16:49
No, you need to set the parameter to the author name, so (depending on what entry you're showing), it would be something like:
Digital Designs 13 Jan 2016 17:56
Ok, thank you. This is working for us.
Is there a way to clean up the resultant url? I have added encode="no" but the url generated still displays as the encoded url.
Low 13 Jan 2016 18:06
The encode="no" parameter will generate a URL that will log the search in the search log, after which you're redirected to the search results with a URL that depend on your global settings (encode queries in your Low Search settings).
Digital Designs 13 Jan 2016 21:30
Ok thanks.
Can we search a relationship field also?We are trying to do this for example:
{exp:low_search:url smart_field_search="yes" result_page="search/results" search:article-author="{article-author}" search:photo-source="{article-author}" search:{article-columnist}{article-columnist:title}{/article-columnist}="{article-author}"}
Low 13 Jan 2016 21:40
This:
...will most likely not work.
If you want to filter by relationship, you have to do so using the parent or child entry IDs: http://gotolow.com/addons/low-search/...
Note that using the Relationships filter in conjunction with the Field Search filter will negate the functionality of the smart_field_search-parameter. Ie, you will only get entries that match all parameters.