March 27, 2012

What is a Feature?

People new to SharePoint must be wondering what a Feature is. So here it is, SharePoint Features are components which adds extra functionality to the site and can by Activated or De-activated by a Farm/Site/Web Admin.


Features can do lot of functions and adds lot of value to a Site. We can create a feature that can add extra menu items or do some validation etc.

Feature consists of two XML files. One is feature.xml and the other is a manifest file (like elements.xml). Feature.xml file simply informs SharePoint that a feature exists and can be activated/de-activated.

An example of feature.xml file is shown below: -
<Feature
  Id="[GUID]"
  Title="Hello World Feature"
  Description="A feature for Praveen's blog"
  Scope="Site"
  Hidden="FALSE"
  ImageUrl="classicmenu.gif"
  xmlns="http://schemas.microsoft.com/sharepoint/">

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

</Feature>

The Manifest file is the one that describes the Feature. For example if a menu has to be added then what should be the menu name, description etc.

An example of a Manifest file is shown as below: -
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <CustomAction
    Id="NewMenu"
    GroupId="SiteActions"
    Location="Microsoft.SharePoint.StandardMenu"
    Sequence="201"
    Title="Hello Menu"
    Description="This is a classic menu"
    ImageUrl="_layouts/images/classicmenu.gif" >
      <UrlAction Url="http://techspoc.blogspot.com"/>
  </CustomAction>
</Elements>

No comments:

Post a Comment