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 am writing a web application-scoped feature which will provision a site collection and a small number of sites.

The problem is that I have my own style files (.js, .css, images) and even some custom pages. If this were a site collection or web-scoped feature, I would use a module to deploy these files. However, modules are not available in web application-scoped features. I could deploy the style files to the _layouts folder, but I would prefer if these files were not available outside my own site collection. That also doesn't solve the problem of my custom site pages.

I was thinking of putting all those files in the _layouts folder, then copying them in the feature event. But I don't really know how to access hive files programmatically.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

I would use a site templates for this, you can then just make your top level site off of it, and have everything encapsulated. It would also house your custom pages etc, doing everything from a single point. (Easier to make as well).

share|improve this answer
    
This seems like the best solution, but might get nasty if the sites need to be changed afterwards –  Spongeroberto Squarepantalones Nov 2 '12 at 15:10
1  
You can create an update with the onet in future versions, even deploy an adapter if you need to handle advanced upgrades. –  Hugh Wood Nov 2 '12 at 15:14

I know this question was asked a while ago now, but for anyone else with a similar problem, I would personally avoid using the site template approach.

Perhaps a better solution (IMO) would be to create a separate site-scoped feature as suggested by Ted N.. The Web App scoped feature would still create the new site but could also activate any site-scoped features on the site after it has been created.

If you did go down the site-template route, then you could also use feature-stapling to ensure the site-scoped feature is activated when the site is first created rather than include the feature in the onet.xml file...

share|improve this answer

It might be worthwhile creating a second, site/site-collection scoped feature in order to deploy all of these assets to a specific site collection.

You could probably write file upload code in your Feature Receiver to effectively do the same thing, but then you would need to configure which site collection to deploy these files to manually -- seems like an unnecessary chore.

If you do want to go down the Feature Receiver path, this might be helpful: Getting Files from Layouts Folder in Sharepoint

share|improve this answer

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.