Help with HubDB filtering

Highlighted
Occasional Contributor

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?

Reply
0 Upvotes
4 Replies 4
Community Manager

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

Reply
0 Upvotes
Occasional Contributor

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

Reply
0 Upvotes
Occasional Contributor

@roisinkirby Any other thoughts on this? 

Reply
0 Upvotes
Occasional Contributor

 

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> 

Reply
0 Upvotes