Monday, July 25, 2011

Activate Publishing Feature in SharePoint

Feature Stappling is one of the gratest feature in SharePoint. It is easiest way of attaching a feature with existing site definitions without disturbing existing template. This feature will work like plug and play concept. Therefore the features can be attached and enabled by default for any site templates. For example activate the Publishing feature when a Blank site created. This feature has two features one is “Stappler” feature which is used for attaching another feature to the site definition. The another one is “Staplee” feature which get attached with site definition. We have a simple feature stappling demo now.

Requirement: Publishing site Feature has to be enabled when a Team Site created in the Site Collection.

Solution:

1. Create a stapler feature and name it as “ActivatePublishingFeature”

2. Find the Staplee Feature GUID because the publishing feature is already deployed in the Farm. In case custom feature, need to use that Feature’s GUID

3. Install the Feature

4. Activate the feature.

Feature.xml

xml version="1.0" encoding="utf-8"?>

<Feature xmlns="http://schemas.microsoft.com/sharepoint/" Title="ActivatePublishingFeature " Id="f7ff397a-65f1-4e82-ad7d-c75111bceef6" Scope="Farm">

<ElementManifests>

<ElementManifest Location="SitePublishingFeatureElement\Elements.xml" />

ElementManifests>

Feature>

Elements.xml

xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<FeatureSiteTemplateAssociation Id="94C94CA6-B32F-4DA9-A9E3-1F3D343D7ECB" TemplateName="STS#0" />

Elements>

Refer this link to get the GUID of SharePoint 2010 default features.

Refer this link to get the SharePoint 2010 default web templates list


1 comment: