CMS Development

Silent2000
Membro

Access to field from one custom module to another

Hi. Can you suggest how resolve my problem? I make two custom HUBL+HTML modules. In one of them I have text field "clickerName" in which I put some value from visual editor. I want to access to this value from other custom module. Any suggestions?

P.S. I already try https://community.hubspot.com/t5/CMS-Development/Sharing-Macros-between-Modules/td-p/202892

and 

https://community.hubspot.com/t5/CMS-Development/How-do-I-access-the-value-of-a-choice-field-from-di...

but no luck

0 Avaliação positiva
7 Respostas 7
albertsg
Orientador(a)

Access to field from one custom module to another

I know this converstation is some weeks old but I find it really interesting, so I wanted to share my experience with something similar in case it helps someone who sees this topic.

 

As you can see here https://community.hubspot.com/t5/CMS-Development/Refresh-module-list-when-loading-new-partial-templa... I tried to have different modules in partial templates and another "parent" module in the main template, then I wanted to share some data between modules/templates. All details in the previous URL.

 

From my experience, if the pages where you have the modules are somehow connected (loading partial templates from another template, for example), I would suggest using one "global module" in your main template so you can access the data from another partial template without the need of more modules. 

 

There are also other solutions to share data between templates, like using macros or a "config file" with a list of properties (for example in JSON format) and they might be more efficient, but this is completely up to you Smiley feliz



Did my answer help you? Mark it as a solution

You also connect with me on LinkedIn or Twitter

Kevin-C
Especialista reconhecido(a) | Parceiro
Especialista reconhecido(a) | Parceiro

Access to field from one custom module to another

Hey again @Silent2000 

 

@alyssamwilie recently answered another question and the solution might be something you could implement. She used HUBL to add data to a JS global, from which it can be used anywhere on the page.

 

Check it out here

 

@tjoyce thoughts?

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
0 Avaliação positiva
Kevin-C
Especialista reconhecido(a) | Parceiro
Especialista reconhecido(a) | Parceiro

Access to field from one custom module to another

Hey @Silent2000 

 

This is my favorite question to answer because the usecases are so vast.

Also the answer is simple and well documented. A win-win!

 

Export to template context might be what you're looking for!

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
tjoyce
Especialista reconhecido(a) | Parceiro Elite
Especialista reconhecido(a) | Parceiro Elite

Access to field from one custom module to another

@Kevin-C - wouldn't you need to know the ID of the module to be able to traverse the  widget_data dict from another module? Wouldn't there be a lot of "hard-coded-ness" involved in that approach? I haven't used the export_to_template_context for anything other than HUBL templates so I'm excited to see your approach to the problem. 

 

Such a common question too.

Kevin-C
Especialista reconhecido(a) | Parceiro
Especialista reconhecido(a) | Parceiro

Access to field from one custom module to another

@tjoyce All valid and important points that would have to be taken into consideration when writing the modules. I may have over simplified my answer.

 

I also didn't investigate that sencond link, my apologies to all. “Wisely and slow; they stumble that run fast.” as was once wisely said lol.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
sharonlicari
Gerente da Comunidade
Gerente da Comunidade

Access to field from one custom module to another

Hi @Silent2000       

 

could you please share more context about the issue you are having? If you could share a screenshot will be perfect. With this information, our experts will be able to help. I will tag so they will be able to advise you.        

 

Hey @tjoyce @prosa @Anonymous  could you please share your knowledge with @Silent2000 ?  

 

Thank you & Happy Friday

Sharon

 


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




0 Avaliação positiva
tjoyce
Especialista reconhecido(a) | Parceiro Elite
Especialista reconhecido(a) | Parceiro Elite

Access to field from one custom module to another

Hi @Silent2000 - Modules are meant to be descrete and it is not recommended that modules share information in that way. This helps modules get published in the marketplace be descrete and not have to have dependecies of other modules. 

 

If you would like to tell us what you're trying to accomplish, maybe we can help you with the approach instead of sharing data between modules.

 

tim@belch.io