Attaching custom features to out of the box SharePoint 2010 site templates on a farm level

In my last article, Modifying SharePoint 2010 out of the box site templates without breaking them, we looked at how you can attach your custom feature to an out of the box site template; the method also known as feature stapling. In that case our custom feature was attached to a site template and activated any time a new site was created on a given site collection.

If you were to create a site on a different site collection where our stapler feature has not been deployed – your new instance of a site would not have your custom action executed.

If you need your custom action executed anywhere on the Farm you need to attach your stapler to the farm level, however in SharePoint 2010 Visual Studio template it’s not as straightforward.

Considering you have the same solution structure we have created in the article above, here is what you need to change:

1. Locate the module where you defined your FeatureSiteTemplateAssociation and locate SharePointProjectItem.spdata file within it (hint – it’s a hidden file so you have to toggle solution explorer view to show hidden files)

2. Open the spdata file and replace the value of SupportedDeploymentScopes to include farm like this:

SupportedDeploymentScopes="Web, Site, Farm"

3. Now, switch to the design view of your stapler feature and switch it`s scope to Farm; once you switched the scope – you will be able to add our new module to the list of items which the stapler feature is able to provision.

That`s it; now, you can deploy your solution and test it. As a result every time you create a new blog anywhere on the farm – you will see an announcement list added to it.

Good Luck!

This entry was posted in sharepoint, sharepoint 2010 and tagged , , . Bookmark the permalink.

Comments are closed.