Hubl & HubDB Filtering Column Values

SOLVE
Highlighted
Regular Contributor

Hello! First, thank you for your time. I am working with a database full of classes (like school work) and I'm trying to display a certain type of class that has been categorized. Each row in my database is basically a class. There are a number of columns, but specifically; I have set 3 categories and I would like to display all the classes in the category "Practice Advancement."

I have followed this tutorial (https://app.hubspot.com/academy/5297945/tracks/34/354/1922) and was successful in accomplishing the task to this effect:

https://connect.woodard.com/2020-all-snh-sessions -- (horay!)

However, you can tell the list is crazy-long. So, long-story-long, I tried to filter out the classes by adding a filter to the loop:

{% for row in hubdb_table_rows(2033946) %}

The above works (I promise). The below does not:

{% for row in hubdb_table_rows(2033946, 'session_category__contains=Practice Advancement') %}

By swapping out the line above, I break the loop and the page will not display much at all. Can anyone help me with the filter I applied, I used the documentation and noticed I could use "__contains" or "__eq"  . . . neither work. "Practice Advancement" might be the issue, but I don't know why as I'm following the direction from the video.

Thank you again for any insight / help with this!

Reply
0 Upvotes
2 Accepted solutions

Accepted Solutions
Highlighted
Top Contributor | Diamond Partner

Try swapping 

?session_category=Practice Advancement

to 

?session_category=1
Highlighted
Regular Contributor

Good news Bryan!

Ok, going back to the documentation didn't help. You were very close actually. I went back and removed the loop surrounding the for-loop. And in doing so I also (purposefully) threw an error in. The text editor found the error and displayed it. So I went through and troubleshot with the error and eventually came to this conclusion:

{% for row in hubdb_table_rows(2033946, 'session_category=1') %}

Which does not work with the "?" or any of the filters supplied in documentations (operators). So, you and I fixed this, but there are problems with HubL in my opinon.

Thank you so much Bryan! I'm going to mark your comment as solution as it did lead to my fix.

Page with the filter working:
https://connect.woodard.com/2020-all-snh-practice-avancement

7 Replies 7
Highlighted
Top Contributor | Diamond Partner

Something like this should work for you, note that you'll want to add the ? mark at the start of the queryparm call and you'll want to use the HubDB Column Name. You'll want to confirm what this is by going into the Hub DB, clicking on the column heading and going to edit and it will show you the column name there, copy that and replace HUBDB-COL-NAME and you should be set!

{% for row in hubdb_table_rows(2033946, '?HUBDB-COL-NAME=Practice Advancement') %}

--
Bryan Schneidewind
Manager of Web Development
Weidert Group 

Highlighted
Regular Contributor

Hello Bryan and thank you for the attempt. I was unable to fix the module with that suggestion. Here is the code I used per your input (both lines are attempts - neither worked) :

{% for row in hubdb_table_rows(2033946, '?session_category__contains=Practice Advancement') %}
{% for row in hubdb_table_rows(2033946, '?session_category=Practice Advancement') %}

Also, here is the setting for the COL in the database:
column_name_settings.png

Reply
0 Upvotes
Highlighted
Top Contributor | Diamond Partner

Try swapping 

?session_category=Practice Advancement

to 

?session_category=1
Highlighted
Regular Contributor

Didn't move the needle Bryan but I love the support so thank you!

I'm going to go through the list and trial-n-error this sonofgun so help me. I'll keep you updated. I'm going to try every option twice from this list:

https://developers.hubspot.com/docs/methods/hubdb/v2/get_table_rows

Reply
0 Upvotes
Highlighted
Top Contributor | Diamond Partner

Can you post the full block of code, that last one should work (I have a similar approach working on a HS site)

Reply
0 Upvotes
Highlighted
Regular Contributor

Good news Bryan!

Ok, going back to the documentation didn't help. You were very close actually. I went back and removed the loop surrounding the for-loop. And in doing so I also (purposefully) threw an error in. The text editor found the error and displayed it. So I went through and troubleshot with the error and eventually came to this conclusion:

{% for row in hubdb_table_rows(2033946, 'session_category=1') %}

Which does not work with the "?" or any of the filters supplied in documentations (operators). So, you and I fixed this, but there are problems with HubL in my opinon.

Thank you so much Bryan! I'm going to mark your comment as solution as it did lead to my fix.

Page with the filter working:
https://connect.woodard.com/2020-all-snh-practice-avancement

Highlighted
Top Contributor | Diamond Partner

Glad it worked out and happy to help!