1

I have a main site collection that is using the stock Publishing Site template in red. All sub-sites are inheriting the master page and theme. All sub-sites are using the Project Site template. I am creating these using the Server Object Model. All the sub-sites are the standard blue after creation. How can I force them to be red?

static void SetupNewSubSite(int currentYear, SPItemEventProperties properties, int siteIndexId)
{
    string description = properties.AfterProperties["Project_x0020_Description"].ToString();
    SPListItem CurrentItem = properties.ListItem;
    String subSiteUrl = Convert.ToString(siteIndexId);
    SPSite projectSiteCollection = new SPSite(properties.Web.Site.Url + "/" + currentYear);           
    SPWeb sWeb = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl);            
    SPWeb oWeb = projectSiteCollection.RootWeb;
    SPWebCollection cWebs = oWeb.Webs;
    SPWeb xWeb = cWebs.Add(subSiteUrl, properties.AfterProperties["Title"].ToString(),
    properties.AfterProperties["Project_x0020_Description"].ToString(), 1033, "{B5B6BDD1-485A-44BC-B093-F1048271C49D}", false, false);
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
calorie712
  • 348
  • 4
  • 14
  • Not sure, but you are using the SPWebCollection.Add() method: http://msdn.microsoft.com/en-us/library/ms412285.aspx. This expects a SPWebTemplate, not a GUID. You say "they are standard blue" - if they inherit the MasterPage, they should have the color of your root web? Or are they not really inheriting? Maybe you just have to inherit upon creation of the web? – Dennis G Oct 08 '13 at 21:06
  • 1
    @moontear Thanks for the link. You can customize a site and save it as a template. Then you have to use the GUID because it no longer has a standard name. The root web is red, the sites that are spawned are blue. If I go in to site settings on the spawned site and click "Change Look" it says "inheriting from parent", which is the root web. – calorie712 Oct 09 '13 at 02:48
  • 1
    One other tidbit. If I go in to the root web site settings and go to Master Page, I can click the check boxes that say "Reset all subsites to inherit this site master page setting". Then all the subsites turn red. – calorie712 Oct 09 '13 at 02:54
  • Very good information. Since you are using code to provision the sites, it would be easy doing what solves your problem by code: Resetting the subsites to inherit. Could you check that after creating a new site and you stop inheriting the masterpage from the root web, then inherit again (change back and forth) - is it still blue or would that make it red as well? – Dennis G Oct 10 '13 at 06:25
  • How do you stop inheriting, then inherit with C#? I tried forcing usage of the parent master page on the new web. It didn't do anything. – calorie712 Oct 11 '13 at 13:32
  • http://sharepoint.stackexchange.com/questions/8151/sp2010-reset-all-subsites-to-inherit-masterpage-using-c – Dennis G Oct 11 '13 at 14:35

0 Answers0