Swapping of template in AEM

Avatar

Avatar

Prashanth96

Avatar

Prashanth96

Prashanth96

19-01-2021

Hi, 

 

Scenario: we have 1000's of pages created based on a certain template, now we are trying to replace the template with a new one for some of the pages. I wanted to know is it possible to swap template for those existing pages?

 

If yes, could you please provide me with the solution how we can approach for the same.

 

@jbrar @Arun_Patidar @kautuk_sahni @BrianKasingli

View Entire Topic

Avatar

Avatar

KiranVedantam1992

Avatar

KiranVedantam1992

KiranVedantam1992

19-01-2021

Hi @Prashanth96,

 

You did not mention which template you are using. Is it a static template or editable?

 

1. For static template, you cannot do the change once the page is created

2. For an editable template, you can modify the template and they will reflect automatically as they maintain a dynamic reference to the page.

 

In your use-case, replacing the old template with a new one, will not work in static templates. For dynamic templates, you can change the below properties in page's jcr:content to make it work

1. cq:template

2. sling:resourceType

 

Note: You might run into errors if the code on the new page component is expecting a different content than what is currently under your jcr:content.

 

I would recommend creating a new editable template and upgrade your changes if your template is static. If it is editable, create different versions of components using a style system, play around with page policies, initial content, and page structure to achieve your desired result.

 

Hope this helps. All the best.

 

Thanks,

Kiran Vedantam.