Friday, September 07, 2007

2003 : Wanna know if a site has a custom theme applied to it?

During upgrading you might be interested in knowing which custom webparts are used on sites or how to migrate the userprofiles but there is another thing that if you don't upgrade it correctly your users will complain about it immediately and that is custom themes! It's pretty easy to figure out which sites (webs actually) do have a custom theme applied to it.

SPGlobalAdmin globAdmin = new SPGlobalAdmin();
SPVirtualServer vServer = globAdmin.OpenVirtualServer(new Uri("portalurl"));
foreach (SPSite site in vServer.Sites)            
    foreach (SPWeb web in site.AllWebs)
        if (web.Theme != string.Empty)
        {Console.WriteLine(web.Url.ToString() + "|"+ web.Theme.ToString());}


It's quite funny to see that you only get a result back if there is another than the default theme is applied.

No comments: