Hubl Widget_data returning 0

Hi all,

I’m wondering if anyone can help please.

I’m trying to get widget data to output within an if statement and for some reason no matter what I try it always returns 0. Other parts of the email template work fine, its just anything within the if. Here’s the code I have below.

{% image ‘cta1-logo’ label=‘(CTA-1) Logo (220x80)’, alt=‘Logo’, src=‘’, export_to_template_context=True %}
{% text ‘cta1-location1’ label=‘(CTA-1) Location Line 1’, value=‘Location Line’, export_to_template_context=True %}
{% text ‘cta1-location2’ label=‘(CTA-1) Location Line 2’, value=‘Location Line’, export_to_template_context=True %}
{% text ‘cta1-date’ label=‘(CTA-1) Date’, value=‘Date’, export_to_template_context=True %}
{% text ‘cta1-url’ label=‘(CTA-1) URL’, value=‘URL’, export_to_template_context=True %}

{% if widget_data.ctano.value > 1 %}
<img src=“{{ widget_data.cta1-logo.src }}” alt=“{{ widget_data.cta1-location1.value }}” width=“220” height=“80” border=“0”>

{{ widget_data.cta1-location1.value }}

{{ widget_data.cta1-location2.value }}

{{ widget_data.cta1-date.value }}

<a href=“{{ widget_data.cta1-url.value }}” title=“”>Link</a>
{% endif %}

As I say each of those return 0, I can’t get it to output user input or even the defaults.

Thanks, Chris.

What is returning zero? Which line?

Where is ctano defined?

If it’s length is what is returning zero, try the length pipe

{% if widget_data.ctano.value|length > 1 %}

Hi,

Sorry no its not the value > 1 bit that isn’t working, thats fine, its everything from within the if statement.

So all the text.values are returning 0, even the .src is returning 0.

Ah! You need to use underscores, HubL doesn’t accept hyphens in module names

So

{% text 'cta1-location1' label='(CTA-1) Location Line 1', value='Location Line', export_to_template_context=True %}

becomes

{% text 'cta1_location1' label='(CTA-1) Location Line 1', value='Location Line', export_to_template_context=True %}

And then update your widget_data lines to reflect this change also.

Ah, that was it! I thought of that at one point but ruled it out early. Knew I should have tested it!

Great stuff thanks so much for the help!

Hopefully this will help someone else in the future.