CMS Development

mansigovani
Contributor

FilterQuery for HubDB Table : HubL

Hello all,

I am trying to filter my HubDB table based on the Page Title. There is a column page_title in my table. And the code I am using is 

{% set pagetitle = page_meta.html_title %}

{% for row in hubdb_table_rows(000000, "&page_title=pagetitle") %}

...................

{% endfor %}

 

How can I use pagetitle as a dynamic variable and not static text itself? Right now it tries to find a value 'pagetitle' instead on actual HTML Page title.

Thank you for your help in advance!

0 Upvotes
7 Replies 7
IsaacTakushi
HubSpot Employee
HubSpot Employee

FilterQuery for HubDB Table : HubL

Hi, @mansigovani.

 

Sincere apologies for the delayed response.

 

You can accomplish this if you define all HubDB filter queries within a HubL string variable.

 

For example:

{% set pagetitle = page_meta.html_title %}
{% set filterquery = "&page_title=" + pagetitle|urlencode %}

{# If you have a complicated query where multiple filters are used, you can keep adding to the filterquery string to chain them. #}

{% for row in hubdb_table_rows(000000, filterquery) %}
  ...
{% endfor %}

Isaac Takushi

Associate Certification Manager
mansigovani
Contributor

FilterQuery for HubDB Table : HubL

@IsaacTakushi , thank you so much for taking time and answering my query. 

I have this 'customer review' form which appears on all the product pages. 

1) On form submission, Zapier's Zap is called.

2) The Zap inserts the data in HUBDB.

3) And then I am using HUBL to call that data/ customer review on the product pages.

 

Currently, all reviews appear on all of the pages. Your answer is the solution to 3) step on how to filter out HUBDB to just show particular product reviews.


But now I have another question on how to send page URL to Zapier to insert into HUBDB?

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

FilterQuery for HubDB Table : HubL

Hi, @mansigovani.

 

Apologies for the delayed response.

 

Your follow-up questions may be better suited for HubSpot support and the Community's APIs & Integrations board, but I'll attempt to answer them here for now.

 

To clarify, do you already have the form > Zapier > HubDB connection established? Can you give me insight into how your Zap's triggers and actions are built out, perhaps with a screenshot?

 

The answer to how to get the page URL to Zapier depends on how you're currently sending the other submission data into that app.

Isaac Takushi

Associate Certification Manager
0 Upvotes
mansigovani
Contributor

FilterQuery for HubDB Table : HubL

Hello @IsaacTakushi ,

Here are the screenshots.

trigger event.png

2.png3.png

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

FilterQuery for HubDB Table : HubL

Hi, @mansigovani.

 

Oh, so you're using a native HubSpot form to trigger the Zap. Can you share a link to the form in your HubSpot account as well as a page where it is embedded?

 

The simplest option may be to add a hidden field on your form and add some custom JavaScript to your pages which populates the form with the page URL.

Isaac Takushi

Associate Certification Manager
0 Upvotes
mansigovani
Contributor

FilterQuery for HubDB Table : HubL

0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

FilterQuery for HubDB Table : HubL

Hi, @mansigovani.

 

Apologies for the delayed response. Thank you for sharing.

 

I'd recommend adding a hidden field for the website URL to your "Customer Review" form.

 

With the window.location object and a little custom client-side JavaScript, you can write the URL to the hidden field to be passed with the firstname, lastname, rating, and comments when the form is submitted.

 

You can then add this field to your Zap to update the HubDB table.

Isaac Takushi

Associate Certification Manager
0 Upvotes