CMS Development

pandapandapanda
Participante

Unique module ID to help reference multiple instances of the module in the same template

resolver

I'm creating a module which requires a reference to an html ID. End users will unlikely know why they need an ID so this ideally should be auto generated.

 

It's also possible to include this module multiple times within a template, so the ID will somehow need to be unique as well.

 

What's the best solution to this?

1 Soluciones aceptada
JasonRosa
Solución
HubSpot Employee
HubSpot Employee

Unique module ID to help reference multiple instances of the module in the same template

resolver

Hey @pandapandapanda you could use the HubL variable of {{ name }} to generate a new ID for each instance of the module on a page. I answered a post a little while back with more details here: https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m.... Let me know if you have any questions about this after reading through that other post!

Ver la solución en mensaje original publicado

3 Respuestas 3
JasonRosa
Solución
HubSpot Employee
HubSpot Employee

Unique module ID to help reference multiple instances of the module in the same template

resolver

Hey @pandapandapanda you could use the HubL variable of {{ name }} to generate a new ID for each instance of the module on a page. I answered a post a little while back with more details here: https://community.hubspot.com/t5/CMS-Development/HubL-Any-way-to-get-the-id-of-the-module-instance/m.... Let me know if you have any questions about this after reading through that other post!

pandapandapanda
Participante

Unique module ID to help reference multiple instances of the module in the same template

resolver

Thanks Jason! That's exactly what I was looking for! Is there a cheat sheet with all these codes somewhere by any chance?

0 Me gusta
JasonRosa
HubSpot Employee
HubSpot Employee

Unique module ID to help reference multiple instances of the module in the same template

resolver

Hey @pandapandapanda, awesome I'm happy to hear that helped! There is a brief doc on this in our designers docs here (https://designers.hubspot.com/docs/modules/reference). More specifically, the built in custom module variables can be found here (https://designers.hubspot.com/docs/modules/reference#module-variables) at the bottom of that article.