The Features framework is something completely new in both MOSS 2007 and WSS 3.0. This framework enables you to package SharePoint functionality (be it a SharePoint list definition, a site definition, some web parts, UI components, or a combination of the previously mentionned ...) and to deploy it in a flexible way on a SharePoint server. It provides a more granular approach for adding functionality since you don't need to wrap your new functionality anymore in a site definition. For a detailed description take a look at Working with Features
What is interesting to now is that the SharePoint team has actually used this feature framework itself to built WSS 3.0 and MOSS. E.g. all the standard built-in list types are created as separate features. You will find them underneath c:\program files\common files\microsoft shared\web server extensions\12\templates\features\ - for an overview of which of these features are linked to MOSS and which to WSS - take a look at What's a MOSS vs WSS feature.
So if you navigate to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\AnnouncementsList you will see the feature.xml for the announcements list.
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="00BFEA71-D1CE-42de-9C63-A44004CE0104"
Title="$Resources:core,announcementslistFeatureTitle;"
Description="$Resources:core,announcementslistFeatureDesc;"
Version="1.0.0.0"
Scope="Web"
Hidden="TRUE"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="ListTemplates\Announcements.xml"/>
</ElementManifests>
</Feature>
If you look at it from a developers stand point a feature is actually nothing more then a couple of XML files and their associated resources. Which are the most interesting "features of features":
- Possible to extend existing sites "Light up"
- Activation and deactivation of features
Every features is scoped at a certain level:
- Farm
- Web application
- Site Collection
- Web
So if you need to deploy a certain component for a specific type of site (so actually a specific site defintion) you can actually use a feature for it - for a complete discussion of how to do this take a look at the post about Feature stapling
So what do you need when you create a new Feature - a very simple feature will just require to simple files:
- MyFeatureName.xml : defines the feature itself and the different components linked to this feature
- Elements.xml : definition of the separate components - the feature.xml actually references Elements.xml
It is also possible to hook up your own event handlers with activation and deactivation event of features. Take a look at Feature Events - these feature provisioning callouts allow you to write code that handle specific events that occur in the lifecycle of a Feature.
The easiest way to learn more about features is to take a look at the OOTB features available as well as to the resources listed below.
Some interesting uses of features:
Creating ContentTypes in SharePoint 2007 by using a feature
Activating Features in a site definition in SharePoint 2007
Making development easier with the SharePoint Feature Manager
Feature Explorer
Adding site colums to Office SharePoint Server by using Features
Adding sub menus to site actions in SharePoint
tags: sharepoint, sharepoint2007, office, moss, wss30
1 comment:
Great survey of some of the cooler aspects of features. Perhaps you have some thoughts on this question I have been noodling: Would it be possible (or would it make sense) to use Features as a mechanism to roll out / enable custom Membership and Role Providers in certain WSS V3 sites. As several articles on using custom providers in WSS point out, deploying them properly involves putting assemblies in the right places and making several modifications to web.config for both the target WSS sites as well as the Central Administration site. Can a feature do all this?
Post a Comment