Quantcast
Channel: The Screwball Division » SitecoreThe Screwball Division
Viewing all articles
Browse latest Browse all 15

Bulk Change Template module

$
0
0

I’ve recently developed a module for Sitecore that allows for changing templates in bulk inside Sitecore. Reason for the module was that I was doing some changes in an existing Sitecore solution where I was facing having to change templates on a quit massive structure of items. Doing this manually would have taken forever and what’s the fun in just creating a temporary script doing this for me. So I decided to create a module that I could reuse.

My requirements were that I should be able to:

  • Select a collection of Items to go through, in this case a root Item.
  • Select a template to search for that could be replaced
  • Select a template that should replace the other template
  • Copy data from fields to others when for example a field would be removed during the change process.

With this in mind I started digging through Sitecore. I have previously created several XmlControls that opens up in dialogues with wizards. However I was facing another problem here. Depending on how many Items where found and how many fields were to be copied, the process could take a while. Thus I needed to find out how to create a “progess bar” the Sitecore way.

After some digging around in the Publishing wizard I found that the Publishing framework was using the JobManager which returned a Handle with which you could send progress status through.

With all this I had everything I needed and got to work. Since the module contains a lot of code I won’t go in to detail on it, but I will link to the source code at the bottom.

Basically it consist of three parts. The command which opens the form in a dialog. The form where you select the root item and the template to find and the template to replace it with, and finally starts the Job. And the Handler which is run using the JobManager and processes everything.

Below are some screenshots and here is the source :)  and! Bulk Template Changer-1.1

Edit: There was a small bug which made the field value copy process to fail when using IE, the links above have been updated with new package and source :)

This is my first actual package that I’ve shared with others, so if you find anything that should be done differently, please contact me :) I will post the package on Sitecore Marketplace as well.

2012-11-19_1 2012-11-19_2 2012-11-19_3 2012-11-19_42012-11-19_5 2012-11-19_6 2012-11-19_7


Viewing all articles
Browse latest Browse all 15

Trending Articles