# Help displaying module fields within if statement in email template

**URL:** <https://community.hubspot.com/t/help-displaying-module-fields-within-if-statement-in-email-template/27617>\
**Category:** Email Marketing Tool\
**Tags:** developer\
**Created:** [November 5, 2020, 12:26am UTC](https://community.hubspot.com/t/help-displaying-module-fields-within-if-statement-in-email-template/27617 "2020-11-05T00:26:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![farser](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/farser/32/33939_2.png) [@farser](https://community.hubspot.com/u/farser)\
**Post date:** [November 5, 2020, 12:26am UTC](https://community.hubspot.com/t/help-displaying-module-fields-within-if-statement-in-email-template/27617/1 "2020-11-05T00:26:48Z")

</div>

I have a custom module with a handful of fields that I want to use to conditionally include an HTML block in an email template.

The first field in the module is a boolean → display\_client\_manager\_message

If that is set to true in the email editor, we present the editor with three fields to edit a custom message:

1. client\_manager\_message → rich\_text
2. client\_manager\_name → text
3. client\_manager\_title → text

The if condition works nicely and I can get the code block within the statement to conditionally display. But I can’t get the value of the module fields to display within the block no matter what I’ve tried from examples in docs, or pasting the snippet from the module editor in the Design Manager…

Please help a HubL noob! 😛

```lia-code-sample
{% module "module_160446479058547" path="/Coded files/Custom/email/default/Client Manager Message", overrideable=True, label="Client Manager Message", export_to_template_context=True %}

{% if widget_data.module_160446479058547.display_client_manager_message == true %}
 <p>Showing our conditional block</p>
 <p>
 {{ module.client_manager_message }}
 </p>
 <p>{{ module.client_manager_name }}<br>
 {{ module.client_manager_title }}</p>
{% endif %}

```

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [November 5, 2020, 5:03am UTC](https://community.hubspot.com/t/help-displaying-module-fields-within-if-statement-in-email-template/27617/2 "2020-11-05T05:03:33Z")

</div>

Hey @farser , with the way you have this written (using widget\_data) I’m under the impression you aren’t writing the code block within the custom module itself? If not then the reason your content isn’t showing is because you aren’t using the widget\_data format on them.

```lia-code-sample
{% module "module_160446479058547" path="/Coded files/Custom/email/default/Client Manager Message", overrideable=True, label="Client Manager Message", export_to_template_context=True %}

{% if widget_data.module_160446479058547.display_client_manager_message == true %}
 <p>Showing our conditional block</p>
 <p>
 {{ widget_data.module_160446479058547.client_manager_message }}
 </p>
 <p>{{ widget_data.module_160446479058547.client_manager_name }}<br>
 {{ widget_data.module_160446479058547.client_manager_title }}</p>
{% endif %}

```

I would just put the code in the custom module itself though instead of using export\_to\_template\_context. It would be a lot cleaner that way. So in the HTML section of your custom module you would put :

```lia-code-sample
{% if module.display_client_manager_message == true %}
 <p>Showing our conditional block</p>
 <p>
 {{ module.client_manager_message }}
 </p>
 <p>{{ module.client_manager_name }}<br>
 {{ module.client_manager_title }}</p>
{% endif %}

```

And then put the module snippet in your template wherever you’re wanting the message to show.

`{% module "module_160446479058547" path="/Coded files/Custom/email/default/Client Manager Message", label="Client Manager Message" %}`

---

<div class="post-metadata">

**Author:** ![farser](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/farser/32/33939_2.png) [@farser](https://community.hubspot.com/u/farser)\
**Post date:** [November 5, 2020, 8:24pm UTC](https://community.hubspot.com/t/help-displaying-module-fields-within-if-statement-in-email-template/27617/3 "2020-11-05T20:24:42Z")

</div>

Works! Thank you so much. I was missing this simple concept. Cheers
