Click here to Skip to main content
14,303,742 members

Feature Stapling in Sharepoint

Rate this:
5.00 (5 votes)
Please Sign up or sign in to vote.
5.00 (5 votes)
26 Jul 2013CPOL
CodeProjectFeature Stapling is a concept using which a specific feature will be stappled to site template.What we gona acheive with it?There will be scenario where certain resource has to be populated to every site collection that was / will be created on a farm.
Feature Stapling is a concept using which a specific feature will be stapled to site template.

What we gonna achieve with it?

There will be scenario where certain resource has to be populated to every site collection that was / will be created on a farm.

Eg : I am dealing a client who is a owning a chemical lab. He want complete list of "Elements and their Atomic weights" to be present in every site that was already created, and any site that will be created in future.

In this scenario, Feature stapling will be used.
Lets see how to demonstrate it.

I have created a sharepoint project in which there are 2 features.
1. Stapled Feature - The feature taking care of creation of the Fields, a Content type and a List from that specific Content Type.
2. Stapling Feature - The feature which will staple the "Stapled Feature" to specific Site template.
Image 1

With Feature #1 : Stapled Feature (Site Scoped), LstContentType will be added to a site and a list called StapledList was getting created with default data i intended to create.

Image 2
Stappled Feature Deployed and Activated

Image 3
LstContentType
Image 4
StapledList

Add a element to project and i names it "StaplingElement". Modify the elements.xml under StaplingElement and add the below XML tag to associate Stapled Feature to site template.
<featuresitetemplateassociation id="934cb12e-f397-41ff-be5a-7d32a085aff0" templatename="STS#0">
Image 5

Now, create second feature #2 Stapling Feature (Farm Scoped), and add the Stapling Element.

Image 6

Deploy the solution (WSP).
Go to Central Admin => System Settings => Manage Farm Features => activate Stapling Feature.
Image 7

Now, create a new Site Collection under a Existing  / New Webapplication using "Team Site" template.

The "#1 Stapled Feature" will be automatically available in new site colection and will be activted. Thus all the above Fields, Content Type,  List and its data will be automatically created by default.

Image 8

How Feature stappling will effect the existing sites?

#1 Stappled feature will be added to exiting sites, but we need to enable the feature in all the existing sites using powershell or manually.

Many of the developers might think different solutions like Custom Site Template, Web Provisioning or Separate WSP with new feature , instead of Feature Stapling. But each solution has a unique scenario which we will discuss the comparison in next post.

Code Smaple: Downlaod Feature stapling.zip from skydrive folder. Image 9

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author


Comments and Discussions

 
Questionthanks Pin
victor_amit2-Oct-13 20:08
membervictor_amit2-Oct-13 20:08 
AnswerRe: thanks Pin
PratapReddyP8-Oct-13 10:20
memberPratapReddyP8-Oct-13 10:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Technical Blog
Posted 26 Jul 2013

Tagged as

Stats

33.3K views
2 bookmarked