|
As described in the previous item, one of the ways to deploy a site columns is by using Features. Features are another important new feature J in MOSS 2007. They are an easy way to deploy changes to a SharePoint environment. You can deploy site columns, content types, assemblies, webpart, menu items and a lot more. This article will not talk about features, but is using features to deploy a site column.
Please note that the code samples you will see are based on a beta version of SharePoint 2007. The actual syntax can be different in later builds of the product.
Features are deployed as files on the server. The can be found in the “FEATURES” folder, which is a subfolder of the “TEMPLATE” folder. In this FEATURES folder, I have created a new subfolder called “fieldstst”. In this folder are a number of files.
Feature.xml The feature.xml file is a general description of the feature and looks like this:
The most important setting here are the Scope, that sets the scope for the feature. This Scope determines the availability of the feature. I have set it to “Site”, which makes my sitecolumns available at the site level. The Location attribute of the ElementManifest element is a reference to the file that has the actual definition of my site column.
Site column feature xml The file fieldtst.xml looks like this:
I think this XML does not need a very detailed explanation. If you are used to working with site definitions and list templates in SharePoint/WSS 2003, you will recognize the syntax.
Installation The actually use the site column, the feature must be installed and activated. This is done in 2 steps by using STSADM:
The first step is to install the feature. In my case this will be like this:
The second step is to activate the feature:
After activating, you need to do an IISRESET, and the site column should be available. In my case it is only available in the “tonportal” portal.
|