466 16.3 Feature Architecture
hidden Feature. The PublishingLayouts Feature is activated upon site collec-
tion creation and provisions all the files and images listed in the Feature defi-
nition into the appropriate document library, such as placing master pages in
the master page gallery. This is just one example of how the implementation
of Features provides core functionality to SharePoint. Examining each of the
default Features in the
FeatureS directory can give you a good understand-
ing of the capabilities that Features bring to the table.
16.3 Feature Architecture
We have stated that a Feature is a package of components that implements a
specific piece of functionality to your SharePoint deployment. But what
does this actually mean, and what does a Feature physically look like? At the
very basic level, a Feature is a folder containing one or more files that define
and deliver the functionality. As previously mentioned, all Feature folders
reside in the
\Program Files\Common Files\Microsoft Shared\Web
server extensions\12\TEMPLATE\FeatureS
directory. If you examine
each of the default Microsoft Feature folders, you will see they each contain
a Feature definition file (Feature.xml). The Feature definition file contains a
Feature element that defines the necessary attributes, properties, activation
dependencies, paths to element definition files, and references to receiver
assemblies. The structure of the
Feature element is shown in Figure 16.3.
The child elements,
ActivationDependencies, ElementManifests,
and
Properties, are all optional elements each further defining the Feature.
We will revisit each of these child elements in a moment, but for now let’s
Figure 16.3
Feature.XML
structure.
16.3 Feature Architecture 467
Chapter 16
focus on the parent element. Attributes of the parent Feature element spec-
ify characteristics such as the title of the Feature as it would appear on the
Feature settings page in the browser user interface. Figure 16.4 and Table
16.1 describe the attributes that are associated with the
Feature element.
Note that only the Feature
Id and the Scope attributes are required for a Fea-
ture to successfully install. A Feature containing these two attributes alone
would not be very useful, but it would install nonetheless, and appear in the
Feature settings page of the specified scope.
The
Scope attribute allows you to define where the Feature will be acti-
vated and on which Feature settings page it will appear. This setting is
restricted to one of the following choices:
Farm, WebApplication, Site, and
Web. If the Scope attribute is set to Farm then the Feature is installed at the
farm level and, if not hidden, appears on the Manage Farm Features page
accessible from the Operations page in the central administration user inter-
face. Features scoped at the farm level are activated automatically by default;
however, this behavior can be controlled by setting the
ActivateOnDefault
Feature attribute. If the Scope attribute is set to WebApplication, the Feature
is installed at the Web application level and, if not hidden, appears on the
Manage Web Application Feature page accessible from the Application Man-
agement page in the central administration user interface. Features scoped at
the Web application level are not automatically activated by default. Again,
this behavior can be controlled by setting the
ActivateOnDefault Feature
attribute. However, this only affects newly created Web applications, existing
Web applications still need to be activated. If the
Scope attribute is set to
Site, the Feature is installed at the site collection level and, if not hidden,
appears on the Site Collection Features page accessible from the Site Settings
Figure 16.4
Feature element
attributes.
468 16.3 Feature Architecture
page at the root of the site collection. If the Scope attribute is set to Web, the
Feature is installed at the individual Web site level and, if not hidden, appears
on the Site Features page accessible from the Web sites Site Settings page. Fea-
tures scoped at the site collection level and the Web site level are not activated
by default and, unlike the
Farm and WebApplication scoping, this behavior
cannot be controlled by the
ActivateOnDefault attribute. It should be
noted, however, that Features scoped at the site collection and Web site levels
are automatically activated upon site creation if they are associated, or stapled,
to a site definition. We’ll discuss the detail of Feature activation and Feature
stapling later in the chapter.
Another important factor that influences the scope of your Feature is
the element type that you are implementing. For example, if you are using
Features to create a content type, then your Feature must be scoped to the
site collection level, as content type Features are not supported at the Web
site, Web application, and Farm levels. The Elements By Scope section of
the WSS 3.0 SDK provides a complete listing of the supported element
types for each scope.
Figure 16.5
Element manifests.

Get Microsoft SharePoint 2007 Technologies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.