Print Custom widget to another template with Hubl


#1

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?


#2

Hi @George_Bratsos,

Have you tried adding the export_to_template_context parameter?


#3

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?


#4

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.