/// <summary> /// Actual sub site creation and modification logic. Calls Core component methods to make things work /// </summary> /// <param name="hostWeb"></param> /// <param name="url"></param> /// <param name="template"></param> /// <param name="title"></param> /// <param name="description"></param> /// <param name="feedType"></param> /// <param name="yammerGroupName"></param> /// <returns></returns> public void CreateSubSite(Web hostWeb, string url, string template, string title, string description, string feedType, string yammerGroupName) { // Create new sub site Web newWeb = hostWeb.CreateWeb(title, url, description, template, 1033); // Set theme for the site newWeb.SetThemeToSubWeb(hostWeb, "Orange"); //Remove the out of the box "NewsFeed" web part newWeb.DeleteWebPart("SitePages", "Site feed", "home.aspx"); // Let's first get the details on the Yammer network using the access token WebPartEntity wpYammer; YammerUser user = YammerUtility.GetYammerUser(ConfigurationManager.AppSettings["YammerAccessToken"]); // Created Yammer web part with needed configuration wpYammer = CreateYammerWebPart(feedType, user, yammerGroupName, title); // Add Yammer web part to the page newWeb.AddWebPartToWikiPage("SitePages", wpYammer, "home.aspx", 2, 1, false); // Add theme to the site and apply that ApplyThemeToSite(hostWeb, newWeb); }
/// <summary> /// Actual sub site creation and modification logic. Calls Core component methods to make things work /// </summary> /// <param name="hostWeb"></param> /// <param name="url"></param> /// <param name="template"></param> /// <param name="title"></param> /// <param name="description"></param> /// <param name="feedType"></param> /// <param name="yammerGroupName"></param> /// <returns></returns> public void CreateSubSite(Web hostWeb, string url, string template, string title, string description, string feedType, string yammerGroupName) { // Create new sub site Web newWeb = hostWeb.CreateSite(title, url, description, template, 1033); // Set theme for the site newWeb.SetThemeToSubWeb(hostWeb, "Orange"); //Remove the out of the box "NewsFeed" web part newWeb.DeleteWebPart("SitePages", "Site feed", "home.aspx"); // Let's first get the details on the Yammer network using the access token WebPartEntity wpYammer; YammerUser user = YammerUtility.GetYammerUser(ConfigurationManager.AppSettings["YammerAccessToken"]); // Notice that in general we do not recommend of matching Yammer group for each site to avoid "group pollution" in Yammer if (feedType == "Group") { // Get Yammer Group - Creates if does not exist. Let's create these as public by default. YammerGroup group = YammerUtility.CreateYammerGroup(yammerGroupName, false, ConfigurationManager.AppSettings["YammerAccessToken"]); // Get Yammer web part wpYammer = YammerUtility.GetYammerGroupDiscussionPart(user.network_name, group.id, false, false); } else { // Get OpenGrap object for using that as the discussion feed wpYammer = YammerUtility.GetYammerOpenGraphDiscussionPart(user.network_name, Request["SPHostUrl"] + "/" + txtUrl.Text, false, false, "SharePoint Site Feed - " + title); } // Add Yammer web part to the page newWeb.AddWebPartToWikiPage("SitePages", wpYammer, "home.aspx", 2, 1, false); }