HubDB - Filtering based on dynamic page data

Trying to create a “related products” section of a dynamic product details page, where a HubDB filter pulls other products based on the current products category column in the HubDB table.

{% for row in hubdb_table_rows(99999, "&categories__contains={{ dynamic_page_hubdb_row.attribute_8_name }}) %}
 <div class="product-listing-grid">
 <div class="product">
 <img src="{{ row.image_1.url|replace('/hubfs/' + hub_id, '/hub/' + hub_id + '/hubfs') }}?width=279" width="279"> {{ row.hs_name }}
 </div>
 </div>
{% endfor %}

My problem is when trying to filter the rows to display only the rows that contain the same categories as the current page/product.

How can I filter based on that dynamic content?

Or do I have to go about it in another way?

@TRooInbound is this something you have seen before?

Hi @calebkenney,

You can create query string and use that string to filter table rows.

Below is your modified code just try out and check it.

{% set CategoryParam = "&categories=" + dynamic_page_hubdb_row.attribute_8_name.id %}
{% for row in hubdb_table_rows(99999, CategoryParam) %}
 <div class="product-listing-grid">
 <div class="product">
 <img src="{{ row.image_1.url|replace('/hubfs/' + hub_id, '/hub/' + hub_id + '/hubfs') }}?width=279" width="279"> {{ row.hs_name }}
 </div>
 </div>
{% endfor %}

We hope it works for you.

Team TRooInbound