Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have read the article about Understanding Scope of SharePoint Features and the MSDN documentation on Feature Scope.

So from what I understand you can activate a feature for the following scopes:

  • Farm
    • Feature will be available throughout the farm, for all web applications.
  • WebApplication
    • Activates the feature for all site collections/sites in the current web application
  • Site
    • Feature will be available on a Site Collection and all children Sites/Site Collections
  • Web
    • Feature will be available only on one Site in a specific site collection

My problem now is that I have a feature I only want to activate for a specific Site (Web) - I have a site collection http://mysharepoint/sites/MySuperSite where I pointed the feature to (SiteURL, Sandboxes Solution=false). But after deploying the feature the feature even is available on newly created Site collections - so when I create a new site collection from central administration, my little feature is already in the feature list, even though I set its scope to "Web".

What did I not understand?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Farm deploys to all web applications.

Web Application deploys to a specific web application.

Your feature will indeed appear in the list for new site collections but it shouldn't be already activated. That's the main difference I think.

share|improve this answer
    
I have a site collection mysharepoint/sites/MySuperSite and deploy a feature Web-scoped. When I now create a site collection mysharepoint/sites/Whatever, the feature is already included (yes, deactivated but I could activate it). Can I not target a feature to be only available in one specific top-level site collection and not be available anywhere else? –  Dennis G Jan 25 '11 at 16:00
    
I don't think features work like that, no. You have them available to activate on entire farms, web applications, site collections and webs. They will always be available to be activated to those levels/scopes, but not switched on unless you staple them to a definition or include them in the site def itself. When you're developing in VS, the F5 deploy will usually go ahead and activate the feature to let you debug it. –  James Love Jan 25 '11 at 16:31
    
Understood - but at the same time you say "available to activate on entire farms..." <-- that's what I want. To only show my feature ONE site collection: I'm talking about its visibility, not the activation. I don't want MySecretFeature to be available in all Sites/Site Collection,but only on one site. –  Dennis G Jan 25 '11 at 16:53
    
I think your option there is to then set it as hidden and activate it on the site of your choosing through PowerShell. –  James Love Jan 25 '11 at 16:58
    
Hidden features? Perfect! :-) –  Dennis G Jan 25 '11 at 22:26

You could create two features:

The first feature is scoped to the Site Collection and is called "Parent Feature". That's it. It does nothing. But it has an Enable button that is visible for all Site collections.

The second feature is scoped to the Web and is called "Real Feature". Real Feature turns on whatever functionality it is that you want. The key is that you set "Real Feature" so that it is dependent on "Parent Feature". That way, "Real Feature" will only show up in sites that live in a site collection where "Parent Feature" has been enabled. On other sites, "Real Feature" won't be visible in the list of Features.

If you want to go further, you can make "Parent Feature" a hidden feature, so that it doesn't show up in the list of Features in the Site collection and has to be enabled via Powershell / code.

share|improve this answer
    
Very interesting approach. –  Dennis G Jan 25 '11 at 22:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.