CMS Development

rossatgrowth
Contributor | Diamond Partner
Contributor | Diamond Partner

Maintain Content when Switching Templates

SOLVE

Hello all,

 

We're doing work for a client who would like to be able to swap templates but keep the content. When using the "Choose a Different Template" option in the builder, instead of keeping the current content it replaces it with the template's default content. The templates all have a very similar layout. Is this something that can be achieved in HubSpot CMS?

0 Upvotes
1 Accepted solution
albertsg
Solution
Guide

Maintain Content when Switching Templates

SOLVE

Hello @rossatgrowth , I believe you could achieve this if all your content is stored in a "main" custom module. 

 

For example, you could have a "big" module with the following variables:

- Template type (this will be a variable that will load one or another partial template)

- Content (main content, create as many content variables as needed)

 

So when you want to populate the page with content, just reference the module variable and that should be it. 

Also, I recommend having a main template that includes the module and use the template type variable in the module to import different partial templates (for example, using IF statements). We did something similar and it works fine!



Did my answer help you? Mark it as a solution


Book time with me

You can also connect with me on LinkedIn



View solution in original post

1 Reply 1
albertsg
Solution
Guide

Maintain Content when Switching Templates

SOLVE

Hello @rossatgrowth , I believe you could achieve this if all your content is stored in a "main" custom module. 

 

For example, you could have a "big" module with the following variables:

- Template type (this will be a variable that will load one or another partial template)

- Content (main content, create as many content variables as needed)

 

So when you want to populate the page with content, just reference the module variable and that should be it. 

Also, I recommend having a main template that includes the module and use the template type variable in the module to import different partial templates (for example, using IF statements). We did something similar and it works fine!



Did my answer help you? Mark it as a solution


Book time with me

You can also connect with me on LinkedIn