Hola! ¡Tenemos nuestra Comunidad en Español!

Using HubDB and Custom Modules for the first time

SOLVE
Esteemed Contributor

Hi all

 

It's my first time using HubDB since we just added CMS. I wanted to create a listings page so decided to follow this guide to get an understanding of the basics. I should mention I've barely touched custom modules in the past but understand the functionality changed quite recently, so this guide may be due an update?

 

https://designers.hubspot.com/docs/tutorials/how-to-build-a-real-estate-listing-with-hubdb

 

I can't seem to get past part 2 on the guide, creating the custom module I face syntax errors preventing me from publishing the module to carry on with following the guide. I wonder if the table needs to be referenced differently as the way custom modules  are created changed.

 

Any help or advice would be greatly appreciated to a novice like myself Smiley Happy

 

Steve

 

Capture.PNG

 

1.
Error:Cannot resolve property " 1036923}, queryparam) "
2.
Error:1:28TemplateSyntaxException: Error parsing ' hubdb_table_rows({1036923}, queryparam) ': syntax error at position 28, encountered '1036923', expected ':'
3.
Warning:8:0Cannot resolve property 'type' in ''
4.
Warning:9:0Cannot resolve property 'listing_image' in ''
5.
Warning:11:0Cannot resolve property 'listing_price' in ''
6.
Warning:12:0Cannot resolve property 'listing_address' in ''
7.
Warning:13:0Cannot resolve property 'type' in ''

 

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
HubSpot Moderator

Hi @Hawk-Steve,

 

I actually don't think the HubL related to HubDB tables has changed since that article. I may need to go through this tutorial a bit more closely, and you're right that it would be good to include something about custom modules. But I think I see the problem in the screenshot you posted (which is very helpful, thank you). For reference, we have some more examples of calling HubDB tables in this article: https://designers.hubspot.com/docs/tools/hubdb, which I think should make clear what's going on in your example.

 

Those curly braces aren't actually intended to be included. So you'll want to call your table with something like this:

 

{% set table = hubdb_table_row(1036923) %}

^This will pull all rows from your table, and you can then loop through them with a for loop like:

 

{% for row in table %}
  {# content here #}
{% endfor %}

...which is what you already have. The reason those warnings like "Cannot resolve property 'type' in ''" is because your table variable itself isn't being created. Once you fix the syntax for creating the table, I'd expect the warnings to go away.

 

The queryparam parameter is for optionally filtering rows on your table. There's a section about filtering in that same article I linked above. Or you can see another example I wrote up yesterday here: https://community.hubspot.com/t5/CMS-Development/Accessing-row-in-HubDB-alternatives-to-WHERE-clause....

 

Hope this helps. If you have any other trouble or questions about things like filtering, let me know here.

 

 - Leland

Leland Scanlan

HubSpot Developer Support
2 Replies
HubSpot Moderator

Hi @Hawk-Steve,

 

I actually don't think the HubL related to HubDB tables has changed since that article. I may need to go through this tutorial a bit more closely, and you're right that it would be good to include something about custom modules. But I think I see the problem in the screenshot you posted (which is very helpful, thank you). For reference, we have some more examples of calling HubDB tables in this article: https://designers.hubspot.com/docs/tools/hubdb, which I think should make clear what's going on in your example.

 

Those curly braces aren't actually intended to be included. So you'll want to call your table with something like this:

 

{% set table = hubdb_table_row(1036923) %}

^This will pull all rows from your table, and you can then loop through them with a for loop like:

 

{% for row in table %}
  {# content here #}
{% endfor %}

...which is what you already have. The reason those warnings like "Cannot resolve property 'type' in ''" is because your table variable itself isn't being created. Once you fix the syntax for creating the table, I'd expect the warnings to go away.

 

The queryparam parameter is for optionally filtering rows on your table. There's a section about filtering in that same article I linked above. Or you can see another example I wrote up yesterday here: https://community.hubspot.com/t5/CMS-Development/Accessing-row-in-HubDB-alternatives-to-WHERE-clause....

 

Hope this helps. If you have any other trouble or questions about things like filtering, let me know here.

 

 - Leland

Leland Scanlan

HubSpot Developer Support
Highlighted
Esteemed Contributor

As always, it's simply a missing . or ; or some other thing! Smiley Very Happy

 

Since posting I had come to the same conclusion, the guide was fine/didn't need updating and I did something wrong, thank you for finding it. Fixing the reference resolved any other warnings following as well.

 

Maybe it's worth tweaking the guide a little to say {Insert YOUR Table ID and remove these squiggly brackets} instead of {Insert YOUR Table ID}. It should keep others like me (HubL newbies) from making the same mistake. Smiley Happy

 

Thanks again Leland!

Reply
0 Upvotes