CMS Development

JZielińska
Member

Filtering HB database with multiple queryparams

Hello

I have a problem, in my template I'm filtering data from HB database

{% for row in hubdb_table_rows(module.hubdbtable_field, queryparam) %}

As queryparam: "&services__contains=digital&limit=2&orderBy=-date"

but it doesn't work. 

this &limit=2&orderBy=-date sets limit and order correctly
it looks like this part &services__contains=digital is not filtering by values in services column.

This is what this column looks like in database, so all names are correct.

JZieliska_0-1642507466073.png

Why the queryparam doesn't filter by the services column? Is this a bad syntax?

0 Upvotes
1 Reply 1
Teun
Key Advisor | Diamond Partner
Key Advisor | Diamond Partner

Filtering HB database with multiple queryparams

Hi @JZielińska ,

 

Could you try one of the following solutions:

{% for row in hubdb_table_rows(module.hubdbtable_field, "services__contains=Digital&limit=2&orderBy=-date") %}

 So remove the first &, and double check if you need to capitalize 'Digital'

or:

{% set rows = hubdb_table_rows(module.hubdbtable_field) %}
{% set digital_rows = rows|selectattr('services','contains','Digital') %}

 



Did my answer solve your issue? Help the community by marking it as the solution.
0 Upvotes