11. Site Template Pros You can modify a site template without affecting existing sites created by the template. Site templates, compared to site definitions, are easy to create and deploy. You can make all customizations through the user interface or SPD. Easy to create - Site templates are easy to create. The site template approach is easier, and just requires the use of the Web interface and occasionally Microsoft SharePoint Designer. No server touch -- Site templates don't require access to the server. Single file deployment -- Because everything you need is in the single STP file, you don't have to worry about putting the files in the correct directories or accidentally creating a conflict. major benefit is that the Page and List definition is read locally from the file system, not from Content Database.
12. Site Template Cons Because the template is just a rubber stamp, applied when you create the site and there is no further connectivity with the template, you can change the template at will. However, your changes won't be reflected in the site. Existing sites will not get affected, if you make any change to the site template. The modification will only affect the new site. Because it is slow to store templates in and retrieve them from the database, site templates can result in slower performance. Doesn't support Publishing Features; No Feature Stapling Site templates are basically black boxes where you have limited control over the way that they are working If the site definition on which the custom template is based does not exist on the front-end server or servers, the custom template will not work. Typically, site templates are not as efficient as site definitions in a large-scale environment
13. Site Definition – What is that? Site Definitions : As the name implies, A Site definition is "core definition of a site”. combination of files that are placed in the 12 hive of WFE during installation of SharePoint. Site definition files include .xml, .aspx, .ascx, and .master page files, as well as document template files (.dot, .htm, and so on), and content files (.gif, .doc, and so on). The site template package is stored as a CAB-based file that can be downloaded or uploaded to site collections by users with the appropriate rights. As before, site templates offer a measure of portability to SharePoint Applications.
14. Site Definition Pros efficient and recommended for a large-scale environment A major benefit is that the Page and List definition is read locally from the file system, not from Content Database. Site definitions typically perform better when cached on the file system instead of in the database. It's a full-fledged part of the SharePoint infrastructure, so almost anything is possible. If you have to include a custom cascading style sheet (CSS), wire up JavaScript events, or change the overall appearance of the page, the best way to do so is through a site definition. Leverages feature framework It is easier to add additional functionality to site which are developed using a site definition They enable complex customizations to be migrated easily from one environment to another Certain functionality, such as declarative content types, custom file types and list views, can only be achieved within a Site Definition
15. Site Definition Cons Existing sites will be affected if you make any changes on to the site definition. Site definitions by contrast require file system access to the SharePoint server, and the ability to reboot Microsoft Internet Information Services (IIS) for your development server. No debugging support -- It's easy to make a mistake in the sparsely documented landscape of site definitions. Requires knowledge of the Site Definition schema and XML Customization of site definition requires more effort than creating custom templates. Editing a site definition after it has been deployed is difficult. Doing anything other than adding code can break existing sites. Users cannot apply a SharePoint theme through a site definition. Users cannot create two lists of the same type with different default content.
16. Core Schema Files for Site Definition Table describes prominent XML files that can be modified for a site definition and shows their locations in the file system.
18. Deciding Between Site Definitions and Custom Site Templates Compare the Pros/Cons of Site Template and Site Definition If you need to make only minor changes in the look of certain pages and add a few fields in particular lists, you should create a custom site template. However, if you need to create new content types, add new Web Part definitions, and significantly restructure sites, you should create a custom site definition. Can you deploy changes to the front-end Web server? If you do not have access to the file system of the computers running Windows SharePoint Services, you have no choice but to create a custom site template. Custom site definitions hold the many advantages over custom site templates:
19. Where the Feature Stapling comes to the picture? When you modify and customize an out-of-the-box site definition, you basically modify its onet.xml, master pages, page layouts, etc and you may also add new master pages, page layouts, web pages, etc. But if in future, you will install any service pack, hot fix, or upgrade to new version, most likely all your changes and customizations will be overwritten . Microsoft doesn't support changes made to a site definition after you've created the sites. Use the Feature stapling with Site definitions is the best option. You can use tools like SP Site Configurator to ease up. http://spsiteconfigurator.codeplex.com/ So if you want to do any modifications or customizations in out-of-the-box site definitions; develop them all as Features and staple them with the respective site definition.
20. Solution Provided by the SharePoint – Feature Stapling In your site definitions, there are several ways of using features with it. These are:- Create a site from the definition and subsequently deploy your features to the site. (STSADM) Include the features in the site definition (onet.xml) before using it to create sites. Use feature stapling to associate your features to the site definition. SharePoint provides a solution to handle such kind of situations, and the solution is Feature Stapling. Feature Stapling allows you to “staple” a Feature to both out-of-the-box and custom site definitions without modifying them in any way. This means you can add your Features to all sites created using that site definition. It is easier to add additional functionality to site which are developed using a site definition in contrast with these built using a site template
21. Include features in site definition - Example This option can be used if the site definition has not yet been deployed, and no sites have yet been created from it. The section of the onet.xml file where features are associated with the site definition as below: <Configuration ID="0" Name="BLANKINTERNET"> <SiteFeatures> <Feature ID="C85E5759-F323-4EFB-B548-443D2216EFB5" /> <Feature ID="A392DA98-270B-4e85-9769-04C0FDE267AA" /> <Feature ID="7C637B23-06C4-472d-9A9A-7C175762C5C4" /> </SiteFeatures> <WebFeatures> <Feature ID="00BFEA71-DE22-43B2-A848-C05709900100" /> <Feature ID="00BFEA71-E717-4E80-AA17-D0C71B360101" /> </WebFeatures> <Modules> <Module Name="Home" /> </Modules> </Configuration>
22. Use feature-stapling to associate your features to the site definition This option should be used when the site definition is already in use (and sites have been created). This is because there are risks in modifying a site definition once it has been deployed (Microsoft doesn’t support this) To use feature-stapling, you first need: the feature(s) you wish to link to the site definition Then, you should create a 2nd feature which does the actual stapling To staple a Feature to a site definition, you actually need to create another Feature that will do the stapling, and this feature is called as Stapler Feature. A feature which is going to be stapled/associated with a site definition is called as Staplee Feature.
23. Example for Feature Stapler Feature.xml file (for stapler feature): <xml version="1.0" encoding="utf-8" ?><Feature Id="82E2EA42-39E2-4B27-8631-ED54C1CFC491" Title="$Resources:MultiLangStaplingFeatureName" Description="$Resources:MultiLangstaplingFeatureDescription" Version="12.0.0.0" Scope="Farm" xmlns="http://schemas.microsoft.com/sharepoint/" DefaultResourceFile="_Res"> <ElementManifests> <ElementManifest Location="Elements.xml"/> </ElementManifests></Feature> Elements.xml file (for stapler feature): <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9-A641-12DB0B9D4130" TemplateName="STS#0" /> <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9-A641-12DB0B9D4130" TemplateName="STS#1" /> <FeatureSiteTemplateAssociation Id="29D85C25-170C-4df9-A641-12DB0B9D4130" TemplateName="SPS#0" /></Elements> In the Above example, FeatureSiteTemplateAssociation element which basically defines the associations between Features and site definitions. In the above example, the stapler feature “staples” the staple Feature with the ID “29D85C25-170C-4df9-A641-12DB0B9D4130” to the STS#0, STS#1, and SPS#0 site definitions. TemplateName="GLOBAL" can be used to deploy for all sites.
24. Resources Best practices resource center for SharePoint 2007http://technet.microsoft.com/en-us/office/sharepointserver/bb736746.aspx Patterns and practices SharePoint guidancehttp://www.codeplex.com/spg Creating a site Definition: http://www.sharepointblogs.com/tbaginski/archive/2007/08/16/creating-a-custom-site-definition-in-wss-v3-moss.aspx Deciding Between Custom Web Templates and Custom Site Definitions http://msdn.microsoft.com/en-us/library/aa979683.aspx Feature Stapling http://msdn.microsoft.com/en-us/library/bb861862.aspx Other resources such as http://www.codeplex.com / http://www.dutchsug.nl / www.microsoft.com/sharepoint