Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, August 17, 2017

Change template of existing Sitecore items without losing data



Change is the law of nature. You can't expect change in already running Sitecore website. Some changes are minor while some changes modified the original logic itself.

Here is a real life scenario:

You have multiple website running on same Sitecore instance. You have one template let’s say "Practice" and you created multiple items(let’s say 100) from this "Practice" templates in multiple websites. Now you have to add some additional fields for only one of the website for Practice related items and require new presentation details.

Here half of the requirement of additional fields can be handlled by adding fields to existing template. But what about adding new presentation details to all items of single website.

One approach is that create new template and apply it to new items. But problem is that we will lost or need to change existing data in new items.

Is there any better approach where we can use same items, get filled data, new fields and new presentation details for one website only?

I use below approach for this

1. Create new template "Practice New" as a copy of existing template "Practice"
2. Applied new presentation details to standard values of template "Practice New".
3. Select Practice item inherited from existing “Practice” template in content tree
4. Change Template
            Select Configure -> Change -> Select "Practice New” -> Next and change existing item to 
new template as

Change Template
Change Template
5. Reset presentation details
            Click on Presentation -> Reset for applying new presentation to the item as


Reset Layout
Reset Layout


6. This is important step as we want to remove all the presentation details from item and want to set default presentation details of new template. So select Reset presentation for every language and its version including both final and shared layouts as

Reset final and shared layout
Reset final and shared layout


7. Apply any data source to items presentation component
8. Publish
9. Test

In short - apply new template, reset presentation details, change data sources and publish item.

I hope you like this Sitecore trick. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this trick if it’s useful for you.

No comments:

Post a Comment