Hi Developers,
I am building a page displaying cards and I want them to be filtered by “title” and “description”. (both text columns in hubdb)
The search works fine when only searching by description, but as soon as I add the “title” search things just won’t work.
I have tried using this code:
<!-- Search Input -->
<div class="search-input">
<label for="description">Search By Title or Description</label>
<div>
<input name="description" type="text" id="search-by" class="autocomplete">
</div>
</div>
<!-- Set Search Paramater -->
{% set queryparam = "" %}
{% if request.query_dict.description != "" %}
{% set queryparam = queryparam~"&description__icontains="~request.query_dict.title|urlencode~"&title__icontains="~request.query_dict.title|urlencode %}
{% endif %}
<!-- Set Table and Queryparam -->
{% set table = hubdb_table_rows(XXXXXXX, queryparam) %}
I have also tried creating two variables, descriptionquery and titlequery and joining the two search results with this attempt:
<!-- Set Search Paramater -->
{% set descriptionquery = "" %}
{% if request.query_dict.description != "" %}
{% set descriptionquery = descriptionquery~"&description__icontains="~request.query_dict.description|urlencode %}
{% endif %}
{% set titlequery = "" %}
{% if request.query_dict.description != "" %}
{% set titlequery = titlequery~"&title__icontains="~request.query_dict.title|urlencode %}
{% endif %}
<!-- Set Table by Query -->
{% set table = hubdb_table_rows(XXXXXXX), descriptionquery + titlequery) %}
Any help is greatly appreciated
