Tag Info

Hot answers tagged

20

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 ...


4

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 ...


4

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 ...


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

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 ...


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

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

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

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> ...


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> ...


2

I would say that, if your site is a custom one, go with the site definition, it is easier to set, to manage and to deploy. If your feature needs to be attached to built-in site definitions, go with the site stapling, if your feature is not changing the base nature of that site definition. The big problem with the feature stapling, is that it gets confusing ...


2

To elaborate some more about the stapling solution. As Microsof says for SharePoint 2007 (but the same is valid for the 2010 version) "Feature stapling is a concept that allows you to attach (or staple) a SharePoint Feature to a SharePoint site definition without modifying the original site definition files in any way". In that sense, stapling is a valid ...


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


2

You should dispose of the SPWeb reference after each feature receiver has executed. public override void FeatureActivated(SPFeatureReceiverProperties properties) { using (SPWeb web = properties.Feature.Parent as SPWeb) { } } Admittedly, feature receivers such as this are one of the few places where you don't "have to" dispose of your SPWeb ...


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

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

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.


1

You shouldn't use Site definitions and use Web templates instead, because of future upgrades and the fact that MS no longer support site definitions . In case you have custom features, you could write them at proper places in the onet.xml file. Association of you custom feature to onet.xml can be done easily as you might know from site definition ...


1

You must create site definition and then add some part of text to onet.xml file look at <SiteFeatures> and <WebFeatures> part : <?xml version="1.0" encoding="utf-8"?> <Project Title="SiteDefinitionTitle" Revision="2" ListDir="$Resources:core,lists_Folder;" xmlns:ows="Microsoft SharePoint"> <NavBars> <NavBar ...


1

I know this is an old question but I hope this might offer an alternative. The alternative is to get the first user who hits the page fire the event to add your navigation. Create a Control Template called Initialiser.ascx. It has a public property galled FeatureGuid. Inside the Page Load event you perform the work of adding the navigation. Elevate ...


1

Figured this one out as well. I added the code (entire control code) for the navigation bar that is on all other sites to the My Sites as well. I got this from the v4.master masterpage. I then hid the navigation bar that My Sites has in my CSS and styled the new control (the one I added) according to my my other sites. I had to create a sitemap for this ...


1

For replacing default.aspx with your custom file, in feature activation receiver, place the following code: SPFile newDefaultPage = // get your custom default page from somewhere SPFile defaultPage = web.RootFolder.Files["default.aspx"]; // saving backup defaultPage.CopyTo("default-old.aspx", true); // copying our custom page over the default ...


1

If you use SharePoint Publishing feature you can change your welcom page through UI (Site Settings -> Look and feel -> welcom page) or you can use PublishingWeb.DefaultPage method in your code.


1

The General Settings contains the "Show user names in survey results?" which is the ShowUser property. I just did a quick test then using PowerShell and a simple survey and the value stuck when changing it both in PowerSell and in the browser general settings page. Here is my powershell script to test: $site = New-Object ...


1

I have just completed something similar. I create a new site collection based on user input for Title, owner, template, metadata defaults, set auditing and retention policies, etc. This is done via a workflow attached to the request list 'ItemAdded' event. I can probably break the workflow process down into digestible pieces ( it will give me incentive to ...


1

Personally, I find that feature stapling is the way to go - I use Site Definitions as a 'stub' to attach features to, and the features actually configure up the site. Later, if you want to add extra elements to your sites you can staple additional features (for future sites) or activate the feature on existing sites. And you can test elements of the ...


1

It seems that you've only activated your feature on the my site host, not the personal sites. The "My Newsfeed" and "My Profile" pages reside on the my site host, whereas the "My Content" resides on the personal site (my site). To staple your feature to every new personal site, you need to staple it to the following template: SPSPERS#0


1

As Steve suggests, SPRoleDefinition is the way to go together with SPRoleAssignment. If you are migrating from SharePoint 2003 to SharePoint 2007 your SPRole class would still work but I suggest migrating that part of code to the new classes.


1

As far as writing a feature, I've outlined how to do that with event receivers here. You'll just need to replace the code to add event receivers with your code to add permission levels and groups. Also, at the bottom of the post I talk about how to staple it to a specific site definition. Permission levels are called roles in the api. You will want to ...


1

Try changing your templatename to GLOBAL, that will take care of all of the site definitions except for the blank site, which you can include as STS#1. The stapling also doesn't work for templates. See my question here on an idea on how to get around this in SP2010: http://www.sharepointoverflow.com/questions/3975/sp-2010-templates-and-feature-stapling



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