Hot answers tagged

34

Feature stapling is a tecnique that allows for a feature to be stapled to a site definition by using a support "stapler" feature that defines which features are attacched to which site definition. This allows for a feature to be automatically activated on a site created from a site definition without the need to modify the definition files (onet.xml). This ...


5

What is your feature doing? Depending on the modifications it makes in code it could touch either config and /or content databases.


5

The perfect site definition is empty. The built-in templates are useless in anything but the simplest solutions. Even if the customer wants exactly what is in the team site template, I still rebuild that as a WSP solution and deply using code. Code is the way to go, because it gives a mix of what the administrators want and what the devs need. the latter ...


5

As each my "mysite" is a new site collection using a Microsoft Site Definition, there is no no-code solution for automatically adding web parts to a page. (Well there is one no-code solution: Someone could sit in central administration add refresh the list of "mysites" and when he sees a new one he could log in and add the web parts, but I think that after a ...


5

rjcup, Your client is likely not the right entity to ask what solution is best. If you're the developer, then you should know best and if your client doesn't trust your judgement, then your client has a problem much greater than how to get something done. If that client knows more about SharePoint than you do, then you have a quite different problem as ...


5

Is your production a multi server farm? I think you are facing the following issue: http://blogs.msdn.com/b/calvarro/archive/2011/11/06/sharepoint-2010-amp-visual-studio-2010-error-ocurred-activate-features-feature-with-id-installed-in-this-farm-cannot-be-added-to-this-scope.aspx It turns out that VS 2010 internally implements a call to the method ...


4

Currently i prefer working with the "minimal site def" just to get an Id, and then use receivers to add the cool stuff. This is mostly due to the fact that I think I get the job done faster and that you can upgrade the solution easier (and in a supported way). I wrote a piece on this a couple of days ago Avoiding Xml Based SharePoint Features - Use The API ...


4

First of all, Start with a new feature to ensure everything is clean. Also, Please note that the configuration for Blank sites is configured(like below) to ignore any features stapled to the Global site definition.The same is true for some other site definitions as well. <Configuration AllowGlobalFeatureAssociations = "FALSE"...</Configuration> ...


4

Don't think it is possible (anyone, fell free to correct me). But you can always do the opposite - staple a custom feature and deactivate the target features from the custom feature event receiver.


3

Add these lines (inside the Elements tag) to an 'Empty Element' project item, then add that Project Item to a Feature (Scoped to Web Application, for example) in the solution.


3

It depends. Normally you can just set the ActivateOnDefault=False in the feauture. Otherwise you can add an EventReceiver containing code to "turn off" the feature(s) you want. You do this by opening your solution in Visual Studio > right click on the solutions top-level > Add new item > Event Receiver <-- By this stage a dialog will open in which you ...


3

The issue is the lists get created after the feature stapling is called in the Site Collection creation process. The My Site is a new Site Collection, not a new subsite, that's why the event receivers don't fire and the manual activation works. I have used a thread pool solution like the one in the link below to delay the execution until the lists have been ...


3

I recommend using a Web Event Receiver to do this, and handle the 'WebProvisioned' method. This can be created as a Site collection scoped feature that will trigger for every sub website that's provisioned.


3

By design ListAdded can be hosted by SPWeb or SPSite only as documented here. So Feature Stapling cannot be avoided if you want to enforce that across the farm. UPDATE: As per MSDN Documentation, If the Receivers tag has no ListTemplateId or ListUrl attribute, the event receiver is registered at the same scope as the Feature. Which means you should not use ...


3

You need to staple to SPSPERS#0 template. See this technet post.


3

Ok so in SharePoint 2010 there is a new player on the field: Custom Web Templates. I am now using them almost exclusively, instead of custom site definitions. Web Templates offer a few benefits over custom site definitions: Pros manifests can be upgraded (this is not supported on site defs!) can run within the sandbox and hence be used for SharePoint ...


3

The issue here is that you are modifying the web parts collection at the same time as iterating through it. You need to build a separate collection and then use that for the deletion e.g.: SPFile page = web.RootFolder.Files["default.aspx"]; SPLimitedWebPartManager wpmShared = page.GetLimitedWebPartManager(PersonalizationScope.Shared); List<WebPart> ...


3

I like to use both Site Definitions and Features to deliver content. I just have to weigh what is needed for the job. If I know the requirements for the web are going to be contained on a few lists, I'd go with one feature and use the OTB site def. If the web is completely customized or needs many features, I'd start with a site def that closely matches ...


3

When doing publishing sites (WCM) I think you really need to use a Site Def, if for nothing else to get an ID, but otherwise I like to keep it empty and use features for everything else, usually coding feature receivers to do the bulk of the work. Over the summer though, I was starting to get convinced by some very smart SharePoint designers that there may ...


3

Feature stappling simply means having a list of features to activate everytime a certain site definition is used (or in natural language stating "Do activate these features when any of the Site definition ID is created"). Basically there is always a Stappler (the actual feature linking one or more site definion ID with the actual features) and a Staplee ...


3

Based on your comment, create a separate feature for page provisioning and add it in FeatureSiteTemplateAssociation after the lists are created and put the feature which adds XsltListViewWebPart third in the order. So by the time the code in feature activated event of third feature is called both Lists and Pages will be available.


3

Use GLOBAL as TemplateName. <?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="{464b78de-c14e-4c88-bd52-00136fc899f4}" TemplateName="GLOBAL" /> </Elements> See Feature/Site Template Association


2

I can suggest you two blogs which I just read because I was planning to do the same as you are. What is feature stapling and how to achieve it here. How to create a list with data whenever a site is created here. Apart from that feature stapling is quite powerful, whatever can be done through feature object model, i.e. feature activation, deactivation ...


2

If I remember correctly the flow is: Site Collection Scoped Features Web Scoped Features Lists Modules Your stapled features would be shot in after Site collection scoped features or Web scoped features (depending on scope) and hence the lists is not guaranteed to be created before the lists. Found a source here: ...


2

We had the same problem. We had a stapling feature that was applying branding to my personal sites. Staplers code ran, but MDS was still active. What we did, was to add a custom control to a personal site master page which deactivated MDS when site was loaded. In this custom control we added if/else check if this code ran once ( by putting value to ...


2

I found the solution. Forgot to publish the content type and run the timer job (content type hub & subscriber). After that everything worked! I don't have to run the timerjobs in the feature (code), it works without it!


2

Technical Details Feature stapling is implemented through a Feature that is specifically designed to staple other Features to one or more site definitions. Feature stapling allows a Feature to be stapled to any new sites created from any site definition or from specific site definitions based on the template name identified in the appropriate WEBTEMP.xml ...


2

If you're trying to associate your feature to the MySite, try this, substituting the GUID of the feature you want activated for the Id. This associates the specified feature to the SPSPERS#0 template (MySite). <?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation ...


2

Depending on how you configured your staples you might want to consider attaching it to the Blog Site template too (most likely you attached it to SPSPERS#0). You would need to target the template BLOG#0 also. Simply add another line to your stapling feature as follows <FeatureSiteTemplateAssociation Id="<GUID OF FEATURE HERE>" ...



Only top voted, non community-wiki answers of a minimum length are eligible