Manage Features

A feature is a type of enhancement that can be plugged into SharePoint. Custom features can be written by developers, but SharePoint itself is built on features as well. For example, many of the capabilities found in SPS are implemented as features that aren’t present in SPF. This makes sense since SPS adds many enhancements on top of SPF.

Features can be used for many types of functionality, such as adding or removing menu commands, creating lists, creating content types, even altering the SharePoint interface using custom ASP.NET controls.

Each SharePoint feature has a defined scope. The scope gives users flexibility in determining where the enhancement is used. Four scopes are available:

  • Website
  • Site collection
  • Web application
  • Farm

For example, take a custom feature that adds a new command to the Site Actions menu. If this feature is scoped to a single website, then only designated websites will have this new command. If this feature is scoped to a site collection, then every website in designated site collections have this new menu command. If this feature is scoped to a web application, then every website in every site collection in designated web applications have this new menu command.

Before a feature can be used, it must be installed. In most cases, a solution package is used to automate the installation of features. By default, when a solution package is deployed, any features that are part of the package are also installed.

Once a feature is installed, it must be activated in order to be used. This is covered next.

NOTE It’s easy to get solutions and features mixed up. Remember, the solution deploys custom code. The feature is just a form of custom code. So, when deploying a solution, a feature may also be deployed. Specifically, the solution copies the feature’s files to each WFE server in your farm. It also installs the feature so that it becomes registered with SharePoint.

Activating and Deactivating Features

When a feature is activated, it becomes usable for one or more websites, depending on the feature’s scope. A web-scoped feature that is activated within a website becomes available in just that website. A site collection-scoped feature that is activated becomes available for all websites in that site collection. You must activate a feature at a level that matches the feature’s scope. In other words, a feature that is scoped to a website cannot be activated for a site collection, and vice versa. The scope is set by the developer inside the feature and cannot be changed. Deactivating a feature allows you to turn off a feature that was previously activated.

SharePoint’s UI provides four screens where features can be activated or deactivated. Each screen corresponds to one of the scopes: website, site collection, web application, and farm. When a feature is activated or deactivated, it is done immediately.

This section provides the specific steps to activate or deactivate features for each scope. Features can also be managed using PowerShell, as is discussed in “Using PowerShell to Manage Features,” later in this chapter.

In terms of activating and deactivating features, all the scopes work the same way: You are presented with a list of features, and you click the Activate or Deactivate button for the feature you want to control. If you deactivate a feature, you must confirm the action.

Website Features Features that are scoped to the website level are the most granular. Deploying features to specific websites gives you precise control over which websites use the features. By default, only hierarchy managers, site owners, or site collection administrators are able to activate or deactivate features for a website. Here are the steps:

1. Click Site Actions ⇒ Site Settings.

2. In the Site Actions category, click Manage Site Features.

A list of website features is shown in Figure 6.13.

Figure 6.13: Activating and deactivating features at the website level

image

Site Collection Features Many types of features, including built-in features, are scoped to the site collection level. It is common to see web parts, master pages, page layouts, content types, and others made available by activating a site collection-scoped feature. For example, by activating a feature, you create a new web part definition in the Web Parts gallery (introduced in Chapter 3).

In general, an activated site collection feature applies to all websites in the site collection. Only site collection administrators are able to activate or deactivate features for a site collection. Here are the steps:

1. Access the top-level website for a site collection.

2. Click Site Actions ⇒ Site Settings.

3. In the Site Collection Administration category, click Site Collection Features.

TIP If you can’t find the feature you want, be sure you are looking at the right screen. In some cases, you may not know the feature scope, so if you can’t find it for one scope, check the other ones. Remember site collection-scoped features are different from website-scoped ones.

Web Application Features Web application-scoped features can be activated and deactivated by using Central Administration. Here are the steps:

1. Click Application Management, then choose Manage Web Applications.

2. Highlight the desired web application.

3. In the ribbon, click the Manage Features button.

Farm Features Farm features have the widest scope—they apply to the whole farm. Be very careful about deactivating farm-scope features, in particular built-in ones, as they have a big impact.

To activate and deactivate farm-scoped features using Central Administration, click System Settings and then click Manage Farm Features.

Using PowerShell to Manage Features

PowerShell gives administrators complete control over managing features. The biggest advantage to using PowerShell is the ability to automate the activation or deactivation of features across a wide number of websites or site collections. Five cmdlets are available when working with features from PowerShell:

Get-SPFeature Returns information about features installed into SharePoint. Information for both built-in and custom features is returned. You can optionally specify a scope to filter the features to those of a certain scope. Here is the basic syntax:

Get-SPFeature [-Web | -Site | -WebApplication | -Farm]

Install-SPFeature Used to manually install a feature. This cmdlet is not typically used by administrators because installation is automated when you deploy a solution package.

Enable-SPFeature Used to activate a feature. Here is the basic syntax:

Enable-SPFeature <FeatureName> -Url <URL>

FeatureName is the name of the folder where the feature is stored. Each feature must have a unique folder located here: Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATEFEATURES.

This example activates a feature for the finance site collection:

Enable-SPFeature BIWebParts -Url image
http://intranet/sites/finance

This example activates a feature for all site collections in the intranet web application:

Get-SPSiteAdministration http://intranet/* -Limit all image
| ForEach-Object {Enable-SPFeature EmployeeSpotlight image
-url $_.Url}

Disable-SPFeature Used to deactivate a feature. It works the same as Enable-SPFeature.

Uninstall-SPFeature Used to manually uninstall a feature.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.79.206