CMS Development

JLarry5001
Member

Adding Class and ID attributes to Custom Sections

SOLVE

Newbie having trouble here. 

My overall problem is that Class and ID attributes are not available on most elements in HS. (Insert rant here)

My solution is to create a new section that has class and id attributes available to the user to edit. I have done this with custom modules but I'm having trouble with sections. Has anyone else had trouble doing this?

0 Upvotes
1 Accepted solution
GiantFocal
Solution
Top Contributor | Gold Partner
Top Contributor | Gold Partner

Adding Class and ID attributes to Custom Sections

SOLVE

Hi @JLarry5001,

 

Sections don't support IDs/classes. Two workarounds you can try:

  1. Develop section-as-module with custom ID and class fields. 
  2. Develop a "Settings" module that appends custom ID and class values to the section it's added into. 

We use approach #2 in all of our HubSpot themes. 

Glad I could help.
Solving HubSpot puzzles is what we do.
Ernesto // GiantFocal


Found this answer helpful?
Marking it as the solution helps both the community and me - thanks in advance!

View solution in original post

2 Replies 2
JLarry5001
Member

Adding Class and ID attributes to Custom Sections

SOLVE

Thanks @GiantFocal!


If you have a moment, could you elaborate on Option 2? I'm just getting started with HubL and am not familiar with how to append class and ID to a parent.

 

I appreciate it.

0 Upvotes
GiantFocal
Solution
Top Contributor | Gold Partner
Top Contributor | Gold Partner

Adding Class and ID attributes to Custom Sections

SOLVE

Hi @JLarry5001,

 

Sections don't support IDs/classes. Two workarounds you can try:

  1. Develop section-as-module with custom ID and class fields. 
  2. Develop a "Settings" module that appends custom ID and class values to the section it's added into. 

We use approach #2 in all of our HubSpot themes. 

Glad I could help.
Solving HubSpot puzzles is what we do.
Ernesto // GiantFocal


Found this answer helpful?
Marking it as the solution helps both the community and me - thanks in advance!