CMS Development

calebkenney
Member

HubDB - Filtering based on dynamic page data

SOLVE

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?

 

0 Upvotes
1 Accepted solution
TRooInbound
Solution
Key Advisor

HubDB - Filtering based on dynamic page data

SOLVE

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

 

View solution in original post

0 Upvotes
2 Replies 2
TRooInbound
Solution
Key Advisor

HubDB - Filtering based on dynamic page data

SOLVE

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

 

0 Upvotes
roisinkirby
HubSpot Product Team
HubSpot Product Team

HubDB - Filtering based on dynamic page data

SOLVE

@TRooInbound is this something you have seen before?

0 Upvotes