Monday, March 8, 2010

How to create a Simple Feature for SharePoint

This feature is simply add the existing file to the existing list.

  • Open the visual Studio and add following file to you empty project. When you are writing the xmls in is better use schema that provides intellicence.
  • To add the XML sheme, in the XML file go to properties and

image

  • after that create following files in you project

image

feature.xml(you cannot change the file name) 




<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
         Id="616CE205-AFD6-4823-9519-2A2AEF7C8BB0"
         Scope="Web"
         Title="Really Simple Feature"
         Description="A feature to place a doc in a library">

  <ElementManifests>
    <ElementManifest Location="elements.xml"/>
  </ElementManifests>

</Feature>




elements.xml




<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Module Name="Document" List="101" Url="Shared Documents">
    <File Url="TextFile1.txt" Type="GhostableInLibrary" />
  </Module>

</Elements>




After create those files copy those 3 files and put them to

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\SimpleFeature

And install the feature to the site using command prompt.

stsadm -o installfeature -n SimpleFeature

This is under

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>

Now the feature installed to your site. To activate the feature goto

Site settings –> Site Features –> realy simple feature.

image

Post a Comment