HubdB Column Data Can't Be Retrieved in a Gallery Slide Block Syntax

556 Views Asked by At

Hopefully, the HubSpot developers here will be nice. I’m trying to retrieve rows data from a hubdb table like this:

{% set gallery = hubdb_table_rows(<tableId>, "<columnName>__contains=<a multi-select columnProperty>") %}
{% if gallery == [] %}
<p class="error__notice"> Sorry, you do not have objects in your database. Try changing the filter </p>
{% else %}
<div class="digi__gallery-items">
{% for row in gallery %}
{% module_block gallery "Gallery" display_mode="standard" sizing="static", transition="slide", caption_position="superimpose", auto_advance=True, overrideable=True, description_text="", show_pagination=True, label="Gallery", loop_slides=True, num_seconds=5 %}
{% module_attribute "slides" is_json=True %}
{
"caption": "<h3>{{ row.authors }}</h3>",
"show_caption": true,
"link_url": "{{ row.main_url }}",
"alt_text": "Screenshot of eP",
"img_src": "{{ row.image.url }}",
"open_in_new_tab": true
}
{% end_module_attribute %}
{% end_module_block %}
{% endfor %}
</div>
{%.endif %}

I’m using the hubl gallery tag (as per the block syntax method with a slide parameter attribute) to loop over an image and link columns as shown in the code block with expectation {{.row.image.url }} returns an image link, while {{ row.image_url }} provide the hyperlink for each slide.

Unfortunately, the aforementioned table data don’t work but, the caption property (Json) successfully pulls up data from the database as shown in the screenshot below. Screenshot of the hubl output What am I doing wrong and could you suggest an easier work-through? THANKS!

1

There are 1 best solutions below

0
On

I figured this out, eventually.

I wasn't aware of the dot between my closing endif until someone spotted it out on Hubspot. My bad.

Well, I succeeded in showing the image by decoding encoded URL strings back to the original URL like this:

{{ row.image.url|urldecode }}

I was also advised to check the documentation for the Gallery tag to understand the object syntax.

"Also, the object you want to display starts with { (curly brackets) but the documentation is telling to start with [ (brackets)," says Indra, a Hubspot diamond partner. 

Anyways, my code has some bugs but my issue was getting the image URL expression to render images from my database with I solved with a filter.

Thanks.