Click here to Skip to main content
15,867,686 members
Articles / Productivity Apps and Services / Sharepoint
Technical Blog

Feature Stapling in Sharepoint

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
26 Jul 2013CPOL2 min read 36.8K   2   2
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.

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.

Stappled Feature Deployed and Activated

LstContentType
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">

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


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

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.


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.
This article was originally posted at http://pratapreddypilaka.blogspot.com/feeds/posts/default

License

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



Comments and Discussions

 
Questionthanks Pin
victor_amit2-Oct-13 20:08
victor_amit2-Oct-13 20:08 
AnswerRe: thanks Pin
PratapReddyP8-Oct-13 10:20
PratapReddyP8-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.