*** Starting Dec 15th my blog will be moved to http://blog.srinisistla.com/. However, until then, I shall post topics at both locations.

Sunday, November 16, 2008

Creating SP Site Feature

This post would make one understand in simple 10 steps how to create and deploy a SharePoint Site Feature (in this case a page).

This is simple but very useful in case of you already have an existing portal and want to deploy a new page / item (could be anything) when there is no provision to modify ONET.xml file.

Step 1 # Create a folder in the web project (you can create any where... using Visual Studio is not a mandate here) with the name of the Site Feature you want to deploy to the SP Site / Web. NewFeaturePage in this example. It is preferable to have no space in the Feature name but thats not mandatory. Best practices suggests to have 'u20' (html encoded) to replace spaces in the feature name.Step 2 # Add a (new) XML File to the folder and name it as Elements.xmlStep 3 # Create a new .aspx page to the folder and name it as NewFeaturePage.aspx (in this example)Step 4 # Add a (new) XML File to the folder and name it as Feature.xmlStep 5 # From VS Designer, TOOLS > CREATE GUID create a new GUID. Use this new GUID in the Feature.xml as shown below for Feature ID.

the contents of Elements.xml can be as simple as below...------------------------------------------------------------------------<Elements xmlns="http://schemas.microsoft.com/sharepoint/"><Module Name="NewFeaturePage" Path="" Url="" ><File Url="NewFeaturePage.aspx" Type="Ghostable" IgnoreIfAlreadyExists="FALSE" /></Module></Elements>------------------------------------------------------------------------the contents of Feature.xml would be as below...------------------------------------------------------------------------<FeatureId="{USE THE NEW GUID HERE}"Title="New Feature"Description="New Feature"Scope="Web"xmlns="http://schemas.microsoft.com/sharepoint/"Hidden="False"><ElementManifests><ElementManifest Location="Elements.xml" /></ElementManifests></Feature>------------------------------------------------------------------------

Step # 6 Copy the NewFeature folder from your project or local folder) to the following location on the SharePoint Server box. If you followed Step 1 - 6 by log in to the SP Server box, copy the folder locally.