Extending Sitecore Revolver to bulk update placeholder names

Saturday, April 18, 2015

While doing some re-factoring of Sitecore Layouts recently I wanted to rename some placeholders. This caused an issue as the old names were heavily referenced within the CMS, both in standard values and directly on some items themselves. After some searching I found that this isn't something that is catered for of out of the box. I decided to extend Sitecore Revolver to create a custom command to handle this.

I created a class that implemented the Revolver.Core.ICommand interface, then performed my processing in the Run(string[] args) method.

The implementation of the class ended up looking like this:

This command reads in two parameters, the old placeholder name and the new placeholder name. I also allowed for a -r switch to passed in to make it run recursively from the context item. To run the command, you first have to bind the it to a moniker using the following Revolver command.

You could then call the rename placeholders command using the rp moniker that it had been bound to, so in order to run recursively you would run it by using the following command:

This would then rename all instances of the old placeholder from every item beneath the item that currently has context within Revolver. After setting this up, the rename task was completed by running this across all of the templates and content items in the tree

The code for this is available on my GitHub.

comments powered by Disqus