Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting – HostForLIFE.eu :: How to Add Promoted Sites Programmatically in SharePoint 2013?
This article will explain you about How to Add Promoted Sites Programmatically in SharePoint 2013. We encountered another problem some days ago wherever we tend to wished to add promoted sites to our User Profile Service application -> My site Settings -> Manage Promoted Sites using PowerShell. Before continuing, we must always understand what promoted sites are. For promoting some of the sites to all or a specific user group, we will use Promoted sites. The following steps shows how to add promoted sites to Central Administration manually.
Go to “User Profile Service application” –> “My Site Settings” –> “Manage Promoted Sites” under Central Administration as shown in the below picture:
Then, choose the “New Link” and fill in the required details for the Promoted Site as shown in the following picture:
Save the Promoted link and go to “Sites” navigation added on Top-Right within the SharePoint page. you may be able to see the recently added promoted web site as shown within the following picture:
You can also add the promoted site using the “Manage” link available, as shown in the below picture:
Now, write the following code to promote Sites link using server-side C# code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
SPSite siteColl = new SPSite("http://abc.com/"); using(SPSite ElevatedsiteColl = new SPSite(siteColl.ID)) { SPUser newUser = ElevatedsiteColl.RootWeb.EnsureUser(@ "mydomain\user"); SPServiceContext serviceContext = SPServiceContext.GetContext(ElevatedsiteColl); PromotedSitesViewWorker.AddSiteLink("http://abc.com/test1", "test1", "test desc1", string.Empty); } Now, you need to add references and the following using statements. using System.Reflection; using Microsoft.SharePoint.Portal; using Microsoft.SharePoint.Publishing; using Microsoft.SharePoint.Portal.UserProfiles; The following PowerShell Snippet will add promoted sites. Add - PSSnapin "Microsoft.SharePoint.PowerShell" - ErrorAction SilentlyContinue; $site = Get - SPSite "http://abc.com/"; $currentUser = [Environment]::UserDomainName + "\" + [Environment]::UserName; $serviceContext=Get-SPServiceContext $site $spuser=Get-SPUser -Web $site.RootWeb.Url -Identity $currentUser $imgUrl=" "; [System.Reflection.Assembly]::Load(" Microsoft.SharePoint.Portal, Version = 15.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c "); [Microsoft.SharePoint.Portal.UserProfiles.PromotedSitesViewWorker]::AddSiteLink($serviceContext,$spuser," http: //abc.com/test1","test12","test 12 decription", $imgUrl); |
SharePoint 2013 Hosting Recommendation
HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options.
Print article | This entry was posted by Peter on May 20, 2015 at 4:47 am, and is filed under European SharePoint 2013 Hosting. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |