CMS Development

pandapandapanda
Participant

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

SOLVE

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 Accepted solution
JasonRosa
Solution
HubSpot Employee
HubSpot Employee

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

SOLVE

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!

View solution in original post

3 Replies 3
JasonRosa
Solution
HubSpot Employee
HubSpot Employee

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

SOLVE

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
Participant

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

SOLVE

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

0 Upvotes
JasonRosa
HubSpot Employee
HubSpot Employee

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

SOLVE

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.