public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
ApplyTheme(properties);
}
/// <summary>
/// Sets master page and css properties for the site collection
/// </summary>
/// <param name="properties"></param>
private void ApplyTheme(SPFeatureReceiverProperties properties)
{
SPSite site = (SPSite)properties.Feature.Parent;
if (site != null)
{
Uri masterUri = new Uri(site.RootWeb.Url + "/_catalogs/masterpage/v4.master");
site.RootWeb.MasterUrl = masterUri.AbsolutePath;
Uri customMasterUri = new Uri(site.RootWeb.Url + "/_catalogs/masterpage/mycustom.master");
site.RootWeb.CustomMasterUrl = customMasterUri.AbsolutePath;
site.RootWeb.SiteLogoUrl = "/_layouts/MyProjectName/Images/mycustomlogo.jpg";
site.RootWeb.AlternateCssUrl = "/Style Library/MyProjectName/css/mycustomcss.css";
site.RootWeb.Update();
}
}
No comments:
Post a Comment