Add Custom Links to the SharePoint 2010 UI as a Feature with or without using Visual Studio - SharePoint Development & Administration + InfoPath

Monday, October 24, 2011

Add Custom Links to the SharePoint 2010 UI as a Feature with or without using Visual Studio

In this article, I demonstrate the process of adding a custom link and group to the UI in SharePoint as a Site Feature without using Visual Studio, as well as using Visual Studio.  

In some cases you may not have Visual Studio installed on a Server running SharePoint, or may just want to quickly add a custom link in the interface such as on the Site Settings page, or the Actions or Settings menu for a Document Library or List.  In other cases you may have a project in Visual Studio containing new functionality to be deployed to a SharePoint environment, that needs to be accessed through adding custom links to the UI.  It makes sense to deploy the custom links as part of the solution feature, so I also explain how to achieve this from a Visual Studio Project.





The purpose of this article is primarily to demonstrate the two methods of adding custom links to the UI in SharePoint 2010 with or without using Visual Studio. I therefore don’t go into detail about the links themselves.  Please refer to other articles on this site for more specific information and examples for adding links to specific pages and menus in the SharePoint UI.  References to some of these examples are provided later in this post.




Adding a custom link to the User Interface without Visual Studio:
First up, I explain the steps required to include a custom action link on the Site Settings page of SharePoint sites without incorporating into a Visual Studio project or solution.  


  • On the Frontend Server, browse to the FEATURES directory using Windows Explorer ( C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES )
  • Create a new Folder in the FEATURES directory with a name that describes the type of feature / link that you are adding (eg. “CustomSiteSettingsLinks”).
  • Inside the new folder, create a text file, and name it “Feature.xml”
  • Open Feature.xml in a text editor and paste the following XML into the file:


<?xml version="1.0" encoding="utf-8"?>
<Feature

 xmlns="http://schemas.microsoft.com/sharepoint/"
 Id="E2974DBC-79E1-4B5D-9A98-C32BFFB1FFE1"

 Description="Adds custom links to the Site Settings page"
 Hidden="FALSE"

 Scope="Site"
 Title="Custom Site Settings Links">
<ElementManifests>
<ElementManifest Location="CustomLinkElements.xml" />
</ElementManifests>

</Feature>

  • Create a second text file named “CustomLinkElements.xml”
  • Open CustomLinkElements.xml in a text editor and paste the following XML into the file:


<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Microsoft.SharePoint.SiteSettings.OnlineHelp"
GroupId="Customization"
Location="Microsoft.SharePoint.SiteSettings"
Sequence="1000"
Title="Online Help with SharePoint 2010">
<UrlAction Url="http://www.master-sharepoint.com/"/>
</CustomAction>
</Elements>


  • Install the feature using STSADM or PowerShell


PowerShell:
Install-SPFeature CustomSiteSettingsLinks
Enable-SPFeature CustomSiteSettingsLinks -Url http://sharepoint2010

STSADM:
stsadm -o installfeature -filename CustomSiteSettingsLinks\Feature.xml
stsadm -o activatefeature -name CustomSiteSettingsLinks -url http://sp2010



Add a custom link to the UI (Site Settings Page) from a Visual Studio 2010 Solution
The process below will achieve the same result, but the custom links are added to a Feature using Visual Studio 2010, which when deployed to a SharePoint farm and activated on a site will display the custom link on the Site Settings page.

  • Create a new empty SharePoint Project, or Use an existing project in Visual Studio
  • Add an “Empty Element” from the list of SharePoint 2010 item templates to the solution with the name “CustomSiteSettingsLinks”.
  • Open Elements.xml and paste the following XML into the file:


<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="Microsoft.SharePoint.SiteSettings.OnlineHelp"
GroupId="Customization"
Location="Microsoft.SharePoint.SiteSettings"
Sequence="1000"
Title="Online Help with SharePoint 2010">
<UrlAction Url="http://www.master-sharepoint.com/"/>
</CustomAction>
</Elements>


  • Add a new Feature to the Project
  • Set the Title of the feature to “Custom Site Settings Links”
  • Set the scope of the feature to “Site”
  • Add the CustomSiteSettingsLinks component to the feature.
  • Add the feature to the solution package if required
  • Build the solution package
  • Install and deploy the solution using PowerShell or STSADM:
PowerShell:
Add-SPSolution –LiteralPath “c:\path_to_wsp\ProjectName.wsp”
Install-SPSolution -Identity ProjectName.wsp -GACDeployment

STSADM:
stsadm –o addsolution –name ProjectName.wsp
stsadm –o deploysolution –name ProjectName.wsp –immediate -allowgacdeployment


Using either method to create the feature, after installing and activating it on a site you should see the new custom link under the “Look and Feel” heading of the Site Settings page titled “Online Help with SharePoint 2010”.

Related:
Apply Permissions to Custom UI Links / Actions in SharePoint Menus and Settings Pages - This post explains how to add Custom Actions to the built-in User Interface that are restricted / visible to users based on permissions. Examples for various scenarios are included in the post.


Tutorial: Add Custom List actions using SharePoint Designer 2010 - This article explains how to use the Custom Actions functionality of SharePoint Designer 2010 to add list action links or buttons to the interface for lists and items in SharePoint 2010.  The multiple areas within SharePoint Designer where this can be done from are explained, including the differences in where the actions are placed and the available functionality of the Custom Action for each method.
Share this article:
Stumble This Delicious
Delicious
submit to reddit
Facebook
MySpace
MySpace

No comments:

Post a Comment