Recently I have requirement to modify the About Me page in My Site.I have create a site feature and in its event receiver added some code. Here is the solution if you have same requirement :
If you want to add Content Editor web part :
string Username = SPContext.Current.Web.CurrentUser.Name;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPWeb web = siteCollection.OpenWeb())
{
if (web.WebTemplate == "SPSMSITEHOST")
{
//About Me Webpart
ContentEditorWebPart contentEditor = new ContentEditorWebPart();
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlElement = xmlDoc.CreateElement("HtmlContent");
xmlElement.InnerText = "<strong>About " + Username + "</strong>";
contentEditor.Content = xmlElement;
contentEditor.ChromeType = PartChromeType.None;
using (SPLimitedWebPartManager manager =
web.GetLimitedWebPartManager("Person.aspx", PersonalizationScope.Shared))
{
manager.AddWebPart(contentEditor, "TopZone", 2);
}
}
}
});
If you want to add custom web part to page:
Add-custom-webppart-to-mysite
Subscribe to:
Post Comments (Atom)
-
In last blog we learn how can we enable footer on SharePoint Online Modern Communication site. If you have not gone through that you can use...
-
One of our client wanted to show Employee Directory and our first suggestion was to build custom SPFx which will fetch data from Azure AD or...
-
Recently I was working on sending mail using smtp server where I stuck on below error: IIS/SMTP - emails are stuck in mailroot/Queue ...
No comments:
Post a Comment