So, how does this template work? Basically the site definition used is the BLANKINTERNET template you can find in the famous 12/template/site templates directory.
When you open ONET.XML you will see several configuration tags. Remember how your site already contains a root site and two sub sites (Press Releases and the hidden Search center)? Well, for the root site, BLANKINTERNET#0 is the one that is being used. For the Press releases subsite it is BLANKINTERNET#1 and there is another one called BLANKINTERNET#2 and that one is for the new subsites you create yourself.
So what happens when you select 'Create site collection' and select the 'Publishing portal' template? Well, that has been defined in the webtemp*.xml files you can find at c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML. You are probably not aware that there is another important file called internetblank.xml which is located at c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML. The contents of that file looks like this:
As you can see, it actually defines your initial site structure and it uses the configurations from the ONET.XML.
In the Webtempsps.xml file you will see a list of all the templates that will show up in the Template picker when you create your site collection. The Publishing Portal definition looks little bit different from the other ones as it uses a provisioning technique to create not only one site but a site structure as has been defined in the internetblank.xml file:
You might think that we are drifting away from the initial objective of this post, but read on and everything will be ok! ;-)
How to create my own Corporate intranet?
This is how I would start:
Create a site collection using the Publishing Portal template Open SharePoint designer and create a new master page Use the minimal master page as a start (you can find an updated version on the Microsoft site) Update the master page to your liking. Add a CSS link after the other CSS links in the master page. Reference a css file, located at the _layouts/1033/styles/yourcompany/ folder. Note: this is what I like, you can also choose to upload a CSS file to your styles library of your site collection. Add imagery to the same location. Reference images in your stylesheet relative to the styleheet path. If you are done, I would suggest to package this as a solution because you don't want to deploy it manually with SharePoint designer. This is a very brief descriptions of what I would do:
Create a new project in Visual Studio Use WSPBuilder (CodePlex) to create the initial folder structure within your project Create a new feature inside the features folder called MyCompanyIntranetLayout and add your master page there. Update your feature.xml and Provisionedfiles.xml in the feature so that it provisions your master page to the _catalogs file of your site collection. Examples can be found plenty on the Net so I don't include one here. Scope the feature to the site collections. Create the MyCompany folder inside the layouts/1033/styles folder of your project Use WSPbuilder to create the WSP file for this and you can deploy it to your farm. Let us face the challengesSo you have deployed you master page, custom CSS and images but they don't show up right? You will first have to activate the feature on your site collection, and change the master page using the site settings -> master page feature. Now, create a subsite and .. damn .. you'll have to do it again.
So, how to solve this. Well now we actually hit a fundamental issue and the objective of this post.
There are two options:
You could create a stapling feature and a feature event receiver to automate this process. You could edit ONET.XML of the INTERNETBLANK site template (don't!) and add the feature and change the Chromemasterurl property. To be honest, the second option I would never suggest. Do not touch the out of the box templates. Instead, you could create a copy of the INTERNETBLANK template and change the ONET.XML there.
So, what is the best option? As a matter of fact, we already build the masterpage as a feature so the question is how to activate it and when. Please read this excellent post from Mart Muller.
StaplingYou actually staple a feature to an existing template Configuration. An example is given below:
This is an excerpt from the elements.xml file of the stapling feature. Have a look at the existing examples and documentation of how to create one. Fact is that stapling gets activated after the site has been created!
Feature event receiverWhy do you need the event receiver? The event receiver is actually a dll which you build using Visual Studio and deploy with your feature in the same package. In your feature.xml file you define an eventreceiver assembly *which is your DLL*. In you DLL you have defined a method which gets called whenever you install or activate the feature. There you can switch out the default blueband.master page and replace it with your own. You can do more there! Like applying custom CSS, theme, setting navigation properties and so on.
Adding the feature to ONET.XMLAnother option would be to add the the feature to the ONET.XML file and change the ChromeMasterUrl property to point to your new master.page.
Make sure that you add the feature before the property because everything in the ONET.XML will be processed sequential. Hey! That is an important difference with stapling! If you have several features that are dependent on each other and which need to get activated in a certain sequence, ONET.XML would be a good place to add them.
An example is shown below:
Wow, when do I use stapling then?
The answer is that you use stapling when you want to add the feature to existing (out of the box) templates or more than one template.
You would not want to change the ONET.XML after it has been used by existing sites (eg. live situation).
What about Themes, page layouts, navigation properties, template selection for subsites and page defaults?
Every time, you face the challenge, will I add the feature through ONET.XML or use stapling. Or: will I modify the site properties through code in the event receiver or will I change ONET.XML properties?
Here are some guidelines which I think work very nicely:
ThemesCreate a custom theme Do not add it to spthemes.xml! Create a feature which uses a event receiver to activate the theme on a web Create a second feature to staple the activations feature to your template configuration(s) Example of a themestapler can be found on CodePlex Custom Page layoutsCreate custom page layouts using SharePoint designer When satisfied, copy them into your Visual Studio project where you define a Feature for your new layouts. This feature will also contain your new master page Create a second stapling feature to provision the files to the _catalogs/masterpage folder of your site collection. Create a event receiver to activate the masterpage or other settings Site and subsite specific settingsI feel very comfortable with creating a copy of the INTERNETBLANK template and then add a webtemp*.xml file for adding the new site template to the list of templates Change settings like navigation inhertiance through ONET.XML:
Change settings like the available template for subsites through ONET.XML:
Change settings like the default page layout through ONET.XML:
Wrap up, rules of thumb!
This post is not the only truth! Feel free to add comments or convince me to do otherwise. Create all customizations initially with SharePoint designer and after a while (first beta) deploy them through Features packaged nicely with WSPBuilder Choose to staple your features whenever possible Create a copy of INTERNETBLANK template and change site, subsite specific settings in ONET.XML. I use it to set add the master page feature and set the default master page. However, you could do that through stapling. Make this new site template also part of your solution! I choose to use the Theme stapling from Codeplex to activate the theme on all sites (specifically for the application pages!) because I do not want to add the theme to spthemes.xml and ONET.XML does not provide a property for that! Add default content to pages using the properties in ONET.XML. Your final Visual Studio solution could look like something like this:
12 template features companylayouts masterpages company.master mylayout.aspx mysecondlayout.aspx feature.xml provisionedfiles.xml companythemechanger feature.xml companythemestapler elements.xml feature.xml layouts 1033 styles companyimages company.css sitetemplates companypublishing xml onet.xml default.aspx themes companypublishing company.inf theme.css GAC themechanger.dll
That is it! Hopefully this chaotic post helps you a little bit on how to design your Corporate Intranet. And yes, using this approach leaves everything uncustomized! So future updates through your visual studio project are reflected immediately on all sites! But keep in mind not to change ONET.XML afterwards.