Wednesday, February 23, 2011

Understanding Scope of a Feature

 Courtesy/Reference/Credits:

SharePoint Features can be scoped to the Farm, Web Application, Site Collection, and Web Site level depending on the purpose of the feature. The Feature scope is determined by the setting of the Scope attribute in the Feature element defined in the feature.xml file.
A sample Feature element tag is given below:
<Feature Id="F62C96CF-79FD-44be-8882-E9BFBD199184" 
    Title="Feature Title" 
    Description="Feature Description" 
    Version="1.0.0.0" 
    Scope="Site" 
    Hidden="false"> 
</Feature> 


Web Site scoped Feature (Scope="Web"):
A Web Site scoped Feature is one that can be activated only at the individual Web site level. List templates, list instances, custom actions, event receivers, etc are the some common elements for web site scoped features. Web Site scoped features can be activated by using one of the following two methods:
  • Run the following STSADM command:
    stsadm -o installfeature -name FeatureFolderName –url http://servername/site/subsite

  • Open the Site Features page in the SharePoint site (Site Actions -> Site Settings -> Modify All Site Settings -> Site Features) and click the Activate button.

Site Collection scoped Feature (Scope="Site"):
A Site Collection scoped Feature is one that can be activated at the site collection level and contains items that apply to the site collection as a whole (for example, content types that are shared across the site collection), as well as items that can be activated per site (for example, list instances, etc). Site Collection scoped features can be activated by using one of the following two methods:
  • Run the following STSADM command:
    stsadm -o installfeature -name FeatureFolderName –url http://servername/site/sitecollection

  • Open the Site Features page in the SharePoint site (Site Actions -> Site Settings -> Modify All Site Settings -> Site Collection Features) and click the Activate button.

Web Application scoped Feature (Scope="WebApplication"):
A Web Application scoped Feature is one that can be activated at the web application level and contains items like administrative web application links, delegate control registrations, feature/site template association, document form registrations, etc. A farm Feature can contain, for example, links to /_layouts pages and files, /_admin pages, and other elements. Web Applicationscoped features can be activated by using one of the following two methods:
  • Run the following STSADM command:
    stsadm -o installfeature -name FeatureFolderName -url http://servername

  • Open the "Manage Web Application Features" page in the Central Admin application (SharePoint Central Administration -> Application Management -> Manage Web Application Features) and click the Activate button.

Farm scoped Feature (Scope="Farm"):
A Farm scoped Feature can be activated at the server farm level. A farm Feature contains a number of elements that are critical for implementing applications and logic anywhere within a deployment. A farm Feature can contain, for example, links to /_layouts pages and files, /_admin pages, and other elements. Farm scoped features can be activated by using one of the following two methods:
  • Run the following STSADM command:
    stsadm -o installfeature -name FeatureFolderName

  • Open the "Manage Farm Features" page in the Central Admin application (SharePoint Central Administration -> Operations -> Manage Farm Features) and click the Activate button.
Note: Farm scoped feature is activated automatically once it is installed on the server farm.


SharePoint Element Types for Features:
The following table describes various element types for Features and shows their possible settings for scope.

Element Description Scope
Content Type Contains a schema definition you can reuse and apply to multiple list definitions.
Site
Content Type Binding Content type binding enables you to provision a content type on a list defined in the Onet.xml schema. Lists defined in the Onet.xml schema cannot be modified directly.
Site
Control A delegate control contains a registration for a well-known control installed on a Web page. This lets you replace existing controls, such as the Windows SharePoint Services search control, with another control.
Farm, WebApplication, SiteWeb
Custom Action You can define the following kinds of custom actions:
·         Content type links for the content type settings page
·         Drop-down menu actions for the drop-down menu that appears for an item
·         Form toolbar buttons for New, Edit, or Display form toolbars.
·         Site Settings link for the Site Settings page.
Farm, WebApplication, SiteWeb
Custom Action Group Defines a group of custom actions.
Farm, WebApplication, SiteWeb
Document Converter Contains the definition of a document converter. A document converter is a custom executable file that takes a document of one file type, and generates a copy of that file in another file type.
WebApplication
Feature/Site Template Association Binds a Feature to a site definition configuration so that created sites are provisioned with the Feature.
Farm, WebApplication, Site
Field Contains a field definition that can be reused among multiple lists.
Site
Hide Custom Action Hides a custom action that has been added through another custom action.
Farm, WebApplication, SiteWeb
List Instance Provisions a SharePoint site with a specific list of data.
SiteWeb
List Template Contains a list definition or template, which defines a list that can be provisioned in a SharePoint site.
SiteWeb
Module Contains a set of files with which to provision sites.
SiteWeb
Receiver Contains an item event receiver registration.
Web
Workflow Contains the definition for a workflow in a list.
Site

No comments:

Post a Comment