CMS Development

alvarofranz
Contributor

Force HubSpot module to take values passed via custom variables instead of ones set via page editor

I am using a template in which I use a module and pass it custom values, that I need to be predefined only for that template.

 

The other instances of said module, should take the values provided via the UI when editing the page.

 

It works fine when creating a page, but when I open the page in edit mode and alter some value, it stops using the custom variables and starts using the values stored in HubSpot, and this cannot be undone.

 

I need to force the module to use the custom values, even if the user edits those in the page editor.

 

This is how I am passing those values (variables are set before, of course):

 

 

 

{% module "hero_banner"
path='../modules/breadcrumb-hero',
label='Breadcrumb Hero',
parent_items="{{parent_items_dic}}",
current_item_label="{{current_item_label_value}}",
offset=0
%}

 

 

 

Thanks.

0 Upvotes
2 Replies 2
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Force HubSpot module to take values passed via custom variables instead of ones set via page editor

Hi @alvarofranz ,

 

I would go for a different approach, you could pass the values in different variables instead of the ones that you registered fields.json, that way, you can do something like this:

{% module "hero_banner"
path='../modules/breadcrumb-hero',
label='Breadcrumb Hero',
parent_items="{{parent_items_dic}}",
fixed_parent_items="Some value",
current_item_label="{{current_item_label_value}}",
fixed_current_item_label="Some value",
offset=0
%}

And in your module, try something like this:

{% set parent_items = module.fixed_parent_items ? module.fixed_parent_items : module. parent_items %}
{{parent_items|pprint}}

That way, your module will use the value of fixed_parent_items if passed from the template, but not in any other cases.

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


alvarofranz
Contributor

Force HubSpot module to take values passed via custom variables instead of ones set via page editor

Thanks for the alternative approach, but note the following:

 

The fixed values don't get passed to the module if they are not part of the original fields definition.

 

The "fixed" fields need to be defined in fields.json, and then there is another problem: hide those fields in the page editor.

0 Upvotes