CMS Development

adrien-gueret
Member

Conditional module

Hi there!

 

As a front-end React developer, I'm discovering Hubspot and I'm quite amazed about its power.
That's said, I have some troubles while trying to include conditionaly a module.

In the UI of the page creation, I want to provide a boolean "Show special feature". So in my HubL template I've written this:

 

{%
      module "hasSpecialFeature"
      path="@hubspot/boolean"
      label="Show special feature"
      export_to_template_context=True
%}

When this special feature is active, I want to provide a new field in the UI, like the color of this special feature. So I've written that:

 

{% if widget_data.hasSpecialFeature.value %}
      Special feature enabled!
      {%
        module "specialFeatureColor"
        path="@hubspot/color"
        label="Special feature Color"
        export_to_template_context=True
      %}
      ... Other stuff ...
{% endif %}

My goal is to provide the color field in the UI only when the boolean is cheched.
That's said, when checked, the text "Special feature enabled!" is well rendered, but the color field does not appear in the UI. I have to reload the page to see it.

Same way when unchecking the boolean : the color field disappear only when I reload the page. It is not a very good UX for the Hubspot creator...

 

What am I doing wrong? 🙂

 

Thanks in advance!
(I may have other silly questions after this one, please don't mind if I create other subjects ^^')

0 Upvotes
3 Replies 3
dennisedson
HubSpot Product Team
HubSpot Product Team

Conditional module

@adrien-gueret , the answer is going to vary based on where you are developing.

if you are using the design manager at app.hubspot.com, you will look for the display conditions on the right pane of the moduleDesign_Manager___HubSpot.png

 

if you are using the local cli (which you should be, you will edit the fields.json file.  I recommend building one in the design manager and then fetching it with the cli so you can see how the fields are built

adrien-gueret
Member

Conditional module

Hi @dennisedson, thanks for your answser!

I'm new to Hubspot, so I indeed use the design manager at app.hubspot.com. I probably should have a look on how to use the local CLI.

 

That's said, if I am not wrong, the solution you suggest concerns conditional fields inside a module. My issue is about conditional modules inside an HubL template.

 

Maybe it's simply something we are not supposed to do?

0 Upvotes
sharonlicari
Community Manager
Community Manager

Conditional module

Hey @adrien-gueret    

 

Thank you for the information provided.I'll tag a few experts that can share their experience with you.    

 

Hey  @daveroma @dennisedson @david_eic  any thoughts you would like to share with @adrien-gueret?

 

Thanks

Sharon


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Upvotes