CMS Development

CephasO
Member

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

SOLVE

Hi guys,

Kindly help out with this.
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.
Screen Shot 2022-06-11 at 07.47.19.png

 

What am I doing wrong and could you suggest an easier work-through? THANKS!

0 Upvotes
1 Accepted solution
Indra
Solution
Guide | Elite Partner
Guide | Elite Partner

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

SOLVE

Hi @CephasO,

 

You should check your code.

For example. In your code at the end you are closing your endif like {%.endif %} (with a dot in between)

This won't work.

 

Also, the object you want to display starts with { (curly brackets) but the documentation is telling to start with [ (brackets).

 

I suggest to check the documentation for gallery.


Indra Pinsel - Front-end developer - Bright Digital
Did my answer solve your issue? Help the community by marking it as the solution.

View solution in original post

0 Upvotes
2 Replies 2
Indra
Solution
Guide | Elite Partner
Guide | Elite Partner

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

SOLVE

Hi @CephasO,

 

You should check your code.

For example. In your code at the end you are closing your endif like {%.endif %} (with a dot in between)

This won't work.

 

Also, the object you want to display starts with { (curly brackets) but the documentation is telling to start with [ (brackets).

 

I suggest to check the documentation for gallery.


Indra Pinsel - Front-end developer - Bright Digital
Did my answer solve your issue? Help the community by marking it as the solution.
0 Upvotes
CephasO
Member

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

SOLVE

Thanks Indra,

I wasn't aware of the dot in-between my endif.
Well, I succeeded in showing the image by decoding encoded URL strings back to the original URL like this

{{ row.image.url|urldecode }}

 I will check the documentation to understand the object syntax you mentioned later. 

Anyways, THANKS for spotting the bugs in my code.