Hola! ¡Tenemos nuestra Comunidad en Español!

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

SOLVE
New Contributor

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?

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
HubSpot Employee

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!

3 Replies
HubSpot Employee

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!

New Contributor

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

Reply
0 Upvotes
Highlighted
HubSpot Employee

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.