APIs & Integrations

WEDIA
Member | Gold Partner
Member | Gold Partner

Print Custom widget to another template with Hubl

Hello all,

I have a problem printing a custom widget that is used from another template with Hubl.

I’ve created a widget

{{ widget.article_summary }}

I use this widget on my Article Template, but also i want this widget to get printed on my Blog Listing template.

I tried this piece of code:
{% for content in contents %}
{{ content.widgets.article_summary.body.value }}
{% endfor %}

This is not working. Any help?

0 Upvotes
3 Replies 3
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Print Custom widget to another template with Hubl

Hi @George_Bratsos,

The first example ({{ widget.article_summary }}) is a statement, and is just evaluated when the page is rendered. Statements aren’t stored as values in the same way that an expression is. The method you now have working ({% text "article_summary" label="Article Summary" %}) is an expression, and therefore stores the value in the context of the template.

0 Upvotes
WEDIA
Member | Gold Partner
Member | Gold Partner

Print Custom widget to another template with Hubl

Hello @Derek_Gervais,

Yes i tried that but it’s not working. I found a workaround without creating a custom widget module from the menus of HubSpot.

So, I created with code this


{% text “article_summary” label=“Article Summary” %}

After i called it on the other template like that

{{ content.widgets.article_summary.body.value }}

It’s working now, but should it be working the same way with a custom module?

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Print Custom widget to another template with Hubl

Hi @George_Bratsos,

Have you tried adding the export_to_template_context parameter?

export_to_template_context

export_to_template_context is a parameter that makes a module's parameters available to the template environment without actually rendering the module. This parameter can be used all HubL module tags. The widget_data tag is used to retrieve these...

0 Upvotes