Change presentation settings on master based items (Sitecore53)

A very well known problem is the fact that beginner Sitecore 5.3 developers might configure presentation settings (renderings/sublayouts) on masters. When there are changes for all the items on a live website, you can change the master but the current items will have the old presentation settings. A way to solve this is to copy/paste the master layout settings to the 'standard values' of the items and reset the presentation settings on the content tree items.

The steps to solve this problem:

1. Copy and paste the layout settings as raw values from the Masters to the 'standard values' of a template and clear the Master layout settings.

2. Create a script that resets the layout settings on the desired content tree items so that the standard values are used instead of the master based settings.

Get all the items you want to change and use the following code in a for-each loop. Activity is the Sitecore item in this case they are all descendants of a node named Activities.

                if (Activity != null && Activity.FieldsRenderings"">"Renderings" != null)
                    using (new Sitecore.SecurityModel.SecurityDisabler())