Jun 11, 20223:11 AM - edited Jun 13, 20226:48 AM
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.
What am I doing wrong and could you suggest an easier work-through? THANKS!
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.