Wednesday, July 8, 2009

All About Features in MOSS 2007

Features allow you to test, deploy, and activate custom functionality inside Office SharePoint Server 2007 and provide a way to make functionality available across your server farm. This functionality can be custom workflows, content types, modifications to the user interface, or new templates for lists and document libraries.

Another benefit of using Features is in the use of site definition (ONET.xml) files. ONET.xml files provide Windows SharePoint Services with information about the navigation, lists, and document libraries that users can create.

Feature Content:

Features are typically stored on the SharePoint server at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES. Each Feature has its own sub-directory that resides in this directory. Inside each Feature's sub-directory, you will find, as a minimum, a header file named feature.xml. The feature.xml file points to a manifest file that tells SharePoint where to find the code and XML that defines the Feature. The feature.xml file contains the Feature element that specifies the location of assemblies, files, dependencies, or properties that support the Feature.

Title="Hello World Feature"

Description="$Resources: core,documentlibraryDesc;"

Version="1.0.0.0" Scope="Web" Hidden="FALSE"

DefaultResourceFile="documentLibrary"

...ImageUrl="menuprofile.gif"

xmlns="http://schemas.microsoft.com/sharepoint/">

ID: The GUID that uniquely identifies the Feature.

Title: The name of the Feature.

Description: The description of the Feature.

Version: The version of the Feature.

Scope: Web or Site are the typical values. The scope defines the context in which the Feature can be activated or deactivated.

Hidden: TRUE or FALSE are allowable values here. This setting specifies if the Feature is visible in the list of Features on the Site Features web page. Setting the attribute to TRUE makes the Feature visible to users who want to activate it.

ImageUrl: Points to an image file that will be displayed next to the Feature in the user interface.

element: The container element for elements.

element: Contains the location of the manifest file that contains the different elements that this Feature implements. The path to sub-directories and files is a relative path.

The manifest file contains details of the different components or actions that make up a Feature. For example, the manifest for an event handler might say, for lists of the specified type, use the class defined in this specified assembly to respond to this specified list item event type, for example, the ItemUpdated event.

Name="ProductName"

SourceID=http://schemas.microsoft.com/sharepoint/v3

StaticName="ProductName"

Group="ProductColumns"

DisplayName="Product Name"

Type="Text">

Install the Feature

After you have created the feature.xml and elements.xml files in a folder, you then need to install and activate the Feature. The process involves three steps.

To install and activate a Feature

  1. Copy the folder containing the two files to the Windows SharePoint Services FEATURES directory.
  2. Run the STSADM.EXE utility to install the Feature.
  3. Run the STSADM.EXE utility to activate the Feature in the context of a Windows SharePoint Services site.

To install and activate the custom Feature

1. Open a command prompt by clicking Start, clicking Run, and then typing cmd.

2. Run the following commands, in sequence.

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

stsadm –o installfeature –filename ctypesWidget\feature.xml

To activate the Feature, run the following command at the command prompt.

stsadm –o activatefeature –name fieldsWidget -url "http:\\localhost"

To deactivate and uninstall the Feature

1. To deactivate the Feature, run the following command at a command prompt.

stsadm –o deactivatefeature –filename "ctypesWidget\feature.xml" -url "http:\\localhost"

2. To uninstall the Feature so that its definition is no longer available within a server farm, run the following command.

stsadm -o uninstallfeature -filename "ctypesWidget

3. Repeat the procedures for the fieldsWidget Feature files.

4. After uninstalling the Feature, reset Internet Information Services (IIS) so that the changes take effect. At the command prompt, type iisreset.

No comments:

Post a Comment