I'm trying to filter entries down based on keywords and also if they have selected a letter that matches the first letter of an entry title on Craft 3.
So far I have this:
{% set keywordParam = craft.request.param('keyword') %}
{% set characterParam = craft.request.param('filterByCharacter') %}
{% set entriesParams = {
section: 'people',
level: 1
} %}
{% set searchArray = ['OR'] %}
{% if characterParam|length %}
{% set searchArray = searchArray|merge(['title:' ~ characterParam ~ '*']) %}
{% endif %}
{% if keywordParam|length %}
{% set searchArray = searchArray|merge(['title:' ~ keywordParam]) %}
{% endif %}
{% if searchArray|length %}
{% set entriesParams = entriesParams|merge({ search: searchArray }) %}
{% endif %}
{% set peopleEntries = craft.entries(entriesParams) %}
At the moment this is producing the error:
Undefined index: query
I've narrowed it down to this line(s):
{% if searchArray|length %}
{% set entriesParams = entriesParams|merge({ search: searchArray }) %}
{% endif %}
But I can't figure out what is wrong with this, and what could be going wrong!
An example URL is:
http://localhost:3000/our-people?keyword=sach&filterByCharacter=M