Features is a new, out-of-the-box feature of MOSS 2007, Features stored on a SharePoint server under the following path: C:\Program files\common files\microsoft Shared\Web Server Extensions\12\template\features. Each featrue has its own subdirectory under this path, and a file named Feature.xml is found in each feature subdirectory, which stores some metadata information about featrue.
Below I use feature to implement a small function, add a custom menu in "website action", first use VS2005 to build a HelloWorld class library project, then add Folder HelloWorld, Add the Feature.xml file code to the folder as follows:
<Feature Id="B2CB42E2-4F0A-4380-AABA-1EF9CD526F20" Title="Hello World Feature" Description="这是我的第一个Feature" Scope="Web" Hidden="FALSE" ImageUrl="TPG\canteen.gif" ReceiverAssembly="HelloWorld, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b38a04419cc857d9" ReceiverClass="HelloWorld.FeatureReceiver" xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml" />
</ElementManifests>
</Feature>
Here's a description of the metadata information contained in the Featrue element.
ID: A GUID that uniquely identifies the feature, which can be obtained using the GUID's build tool;
Scope: The value can be either Web or site, which indicates whether the feature is applied to the entire site collection or only to a single subweb. If you scope= web, activate under [Site Actions-Site Settings-Site Administration-site features], if scope= "site" to activate under [Website actions-Site Settings-Site Administration-site collection features].
Hidden: Value can be true or false. This setting specifies whether this feature is displayed on the Site feature page.
Defaultresourcefile: The name of the resource file, feature relies on it to provide additional configuration information.
<ElementManifests> element: This element contains the location of another XML file, and the content of the <Elemnets> contained in this file is feature to implement.
Then we add the Elements.xml file with the following code:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="SiteActionsToolbar" GroupId="SiteActions" Location="Microsoft.SharePoint.StandardMenu" Sequence="100" Title="Hello World" Description="使用feature方式自定义菜单" ImageUrl="_layouts/images/crtsite.gif">
<UrlAction Url="http://msdn.microsoft.com" />
</CustomAction>
</Elements>