Skip to main content

Cloud

Detecting Un-Ghosted/Customized Master Pages

I recently came across an issue with customized master pages.Updates were made to the master page within the Visual Studio solution, compiled into a wsp, and deployed.

 

This seems to be a common problem if the SharePoint administrators allow for SharePoint Designer customizations, or even by developers downloading master pages from the gallery, making changes to them, and uploading the newly saved file. So you ask, how does one determine if a master page has been customized? If the master page was edited in SharePoint designer, the solution is easy. This can be determined by viewing the master page in SharePoint Designer. If there is a blue “i” icon to the left of the master page, it has been customized.

 

Ghosty

 

 

However, if the master page was customized on a clients computer, saved, and re-uploaded to the master page gallery, a very small amount of code will have to be written to discover the customized status of each master page.

 

Create a console application in your development environment and add a reference to the Microsoft.SharePoint.Within Program.cs, add a using statement to the top of the file:

 

using Microsoft.SharePoint;

 

Create the following code within the Main method of the console application.

 

Console.WriteLine(“Please enter the Url for the site collection root site:”);

string siteColUrl = Console.ReadLine();

string masterPageGallery = “Master Page Gallery”;

using (SPSite site = new SPSite(siteColUrl))

{

SPList list = site.RootWeb.Lists[masterPageGallery];

foreach (SPListItem item in list.Items)

{

if (item.File.Name.ToUpper().Contains(“.MASTER”))

{

Console.WriteLine(“File Name:t{0}tStatus:t{1}”, item.File.Name, item.File.CustomizedPageStatus.ToString());

}

}

}

Console.WriteLine(“Operation Complete.”);

Console.ReadLine();

 

Running this application, and pointing it to your site collection Url will return information on the customized status of all master pages within the gallery.

 

 

Ghosty

 

Now that this has been identified, the following blog shows how to re-ghost the master page.

 

http://mosshowto.blogspot.com/2008/10/re-ghost-master-pages-sharepoint.html

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

PointBridge Blogs

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram