- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Create a filter using two HubDB Text Columns
SOLVEOct 29, 2020 6:14 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Nov 3, 2020 1:50 PM
I have resolved the problem by combining the Title and Description into one Rich Text column and searching the single column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content