0

I have a Low Search form which I'm using to perform simple text searches with on a collection. However I would like to also include the ability to search for all entries beginning with a specific character (A, B, C etc).

MY existing Low Search results tag is as follows:

{exp:low_search:results
        channel="book_authors"
        default:orderby="title"
        default:sort="asc"
        query="{segment_3}"
        result_page="explore/library/authors"
        limit="20"
        }

How would I now pass to this results page a search string which will return all authors with surnames (field name {a_surname}) beginning with 'A' for example?

Update:

Thanks to the pointers from Low I got this working with the following code:

{exp:low_search:results
        collection="book_authors"
        default:orderby="title"
        default:sort="asc"
        {if get:search:a_surname}search:a_surname="^{get:search:a_surname}"{/if}
        result_page="explore/library/authors"
        limit="20"
        }
0

Use the Field Search filter, and specifically, the starts_with parameter:

search:a_surname="A" starts_with="search:a_surname"

Which is identical to:

search:a_surname="^A"
| improve this answer | |
  • Thanks, I'll give that a whirl... will that work alongside the query="" parameter or will I have to get creative with that? – Nathan Pitman Feb 11 '15 at 20:56
  • As with all Low Search parameters, you can hard-code them in the Results tag or add them to your Form as input fields. Or, for the first example, use one in your Form, the other on the Results tag. Capisce? – Low Feb 11 '15 at 21:31
  • Thanks, that worked a treat, removing the query= tag and wrapping the search:a_surname in a {if get:search:a_surname} conditional. :) – Nathan Pitman Feb 13 '15 at 14:11
  • That's one way of doing it. If you're using GET vars, you can also just let the search:a_surname=a in the query string, and use starts_with="search:a_surname" on the Results tag. Slightly safer. – Low Feb 13 '15 at 17:41
  • Yup but I also want the results tag to act upon a normal keyword search too... which I'm guessing this would prevent... :? – Nathan Pitman Feb 15 '15 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.