CMS Development

cph_design
Contributor

Help with HubDB filtering

Hello,

We are trying to have certain products show on a page based on the URL matching with text in a column {{ composer_name }} 

We are having problems with this code, specifically the error we are recieving when trying to save is "TemplateSyntaxException: Error invoking function 'hubdb_table_rows".

{# Get Team Members from HubDB #}

{% set queryparam = "" %}

{% set composer_name = request.path|cut("/composers/") %}

{% set queryparam = queryparam ~ "&composer_name_new={{ composer_name }}" %}

{% set table = hubdb_table_rows(123456, queryparam) %}

<div class="product-container">
  
  {% for row in table %}

            <div class="product">
                <a href="{{ row.product_url }}">
                    <img src="{{ row.product_image_src }}" >
                    <h3>{{ row.product_title }}</h3>
                </a>    
           </div>

    {% endfor %}

</div>

 Does anyone have any ideas on how to resolve this error?

0 Upvotes
4 Replies 4
cph_design
Contributor

Help with HubDB filtering

 

I found a solution by using this documentation https://designers.hubspot.com/docs/hubl/hubl-supported-filters under 'sort'!

 

123456 = your table number

productTitle = the column by which you want to sort with

 

{% set queryparam = "" %}
{% set table = hubdb_table_rows(123456, queryparam) %}
{% set composer_name = request.path|cut("/composers/") %}

{% set queryparam = queryparam ~ "&composer_name_url=={{ composer_name }}" %}

<div class=“product-container”>
 
 {% for row in table|sort(False, False, 'productTitle') %}
 
           <div class=“product”>
               <a href="{{ row.productUrl }}">
                   <img src="{{ row.imageUrl }}" />
                   <h3>{{ row.productTitle }}</h3>
               </a>    
          </div>

   {% endfor %}

</div> 

0 Upvotes
roisinkirby
HubSpot Product Team
HubSpot Product Team

Help with HubDB filtering

Hey @cph_design could you please shar a link to the page you are working on?

0 Upvotes
cph_design
Contributor

Help with HubDB filtering

@roisinkirby Any other thoughts on this? 

0 Upvotes
cph_design
Contributor

Help with HubDB filtering

https://music.cph.org/composers/test-db <- link to the page we are working on

0 Upvotes