Tuesday, June 9, 2009

Custom Site Defintion and Feature stapling issue

Scenario:
We had 2 requirements
1. Develop a custom site definition
2. Develop a feature which is applied to only Out of Box defintions and not to the Custom Definition developed in step 1.

Here's how we had our feature stapling elements
Stapling:

<FeatureSiteTemplateAssociation Id="FEATURE_GUID" TemplateName="GLOBAL" />
<FeatureSiteTemplateAssociation Id="FEATURE_GUID" TemplateName="STS#1" />
Now the issue was it was applying the feature ( FEATURE_GUID ) to Custom Site Definition also.

Solution:
Site Definition declaration support an attribute AllowGlobalFeatureAssociations which can be set to FALSE to avoid binding with GLOBAL. STS site definition also uses the same technique.

Code:
<?xml version="1.0" encoding="utf-8"?>
<Templates>
<Template Name="CustomSiteDefinition" ID="10099">
<Configuration ID="1" Title="Custom Site Definition" Description="A site for teams to quickly organize, author, and share information. It provides a document library, and lists for managing announcements, calendar items, tasks, and discussions." Hidden="FALSE" ImageUrl="/_layouts/images/Client/Custom Site DefinitionLogo.jpg" DisplayCategory="Client" AllowGlobalFeatureAssociations="FALSE" />
</Template>
</Templates>
Article:
http://msdn.microsoft.com/en-us/library/ms476942.aspx
Follow on Twitter

0 comments: