Creating Web Templates for SharePoint 2010


Published on

Web Template slide deck used at SPS Sacramento Oct 13, 2011.

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Site definitions are the classic xml files, which are for example used to provision out of the box sites. Many of the developers learned to create these in 2007 version, since they are very powerful and there were almost no other options available for introducing new options for the Create site functionality. As mentioned earlier site definition consists basically from two different files: WebTemp*.xml and onet.xml files.WebTemp*.xml defines how the site definition is visible for the end users and the onet.xml file contains the definitions for the actual site provisioning.We can only deploy site definitions using farm solutions, since files will be located in the file system. Primary purpose of the feature stapling is to extend and customize existing site definitions. Usually these are used to provide some custom functionalities for the out of the box site definitions, but technique is definitely available also for the custom site definitions. functionality used for saving existing sites as templatePortal provisioning providers are technique where we completely replace the onet.xml file using code (works with custom code)
  • There is always custom code as well
  • 1 From the site actions menu Clicking New Site provides the standard site Creation options.2 These sites are created through the Elements.xml file in the feature folder3 The Elements.xml file uses the onet.xml file to load features that define the website4 Once the site is created, it doesn’t reference the web template elements.xml and onet.xml file but the underlying Site Definition that is the basis for the web template (defined by the BaseTemplateID, BaseTemplateName and BaseConfigurationIdMakes for future upgrades easier (in theory)
  • If the onet.xml file is not set as DeploymentType:ElementFile you will get a cryptic HRESULT errorIf the Name element in the element.xml file does not match the parent folder name you will also get the HRESULT error – this you usually won’t find on Google.Beware copy and paste errors. You may think you have everything, but sometimes you may not copy all the code or may need to change elements that you fail to change.
  • Conclusion slide
  • SharePint
  • Creating Web Templates for SharePoint 2010

    1. 1. Mark CollinsSenior SharePoint ConsultantKiefer Consulting
    2. 2. How can sites be created?• Site Definitions• Feature Stapling• Site Templates• Custom Code• Provisioning Providers• Web Templates
    3. 3. Method PRO CONSite Definition Powerful method for site • Farm Level Solution creation – only way to create • Can’t be changed once a site has been built customized sites in 2007 using the definition • Generally not supported in hosted/online servicesFeature Stapling Extends existing site definitions • Only activated at site provisioning • Doesn’t provide new site definitions only extends existingSite Templates • Easy to create using the UI • Do not work with publishing features enabled • Can be stored off and • Only available in site collection where created modified using Visual Studio unless exported to Visual Studio and deployedWeb Templates • Can be deployed as farm or • Does not support variations site scoped • Feature based so items are stored in the DB, making them Cloud friendly • Can be used with publishing features turned on • Created in Visual StudioProvisioning • Flexible code based system • Require WebTemp*.xml on file system so areProviders generally not supported by Cloud systems • Potential to be deprecated
    4. 4. 1 14TemplateFeature<Feature Folder> Elements.xml XML 2 Onet.xml XML XML 14TemplateFeature<Feature Folder> Onet.xml14TemplateSiteTemplates<base> 3 XML 14TemplateFeature<Feature Folder> 4 features.xml
    5. 5. How to create Web Templates• Open Visual Studio• Create a blank SharePoint Project• Create Folders for the various items that you will be using – Images (Mapped SharePoint Folder) – Lists (For any custom lists that you will be creating) – ContentTypes (for custom lists) – PropertyBag (used to identify the template after it has been created) – WebTemplates (where the web templates will be created) – SitePagesModule (Location of the pages to be deployed with the web template)
    6. 6. How to create Web Templates• Create any content types need for list• Create any lists that will be used• Add any images that are needed by the project• Create the property bag element• Create any page modules and page layouts that will be used by the web template
    7. 7. How to create Web Templates• Add Features to the project – Farm scoped features for web templates used to create top level sites – Site scoped features for web templates that are used to create sites within the site collection – Create features for each of the property bags (web scope) – Create features for the lists and page modules (web scope)
    8. 8. How to create Web Templates• Add an empty element under the WebTemplates directory• Edit the empty element and add a <WebTemplate> Element with the name the same as the parent element• Add a Onet.xml file to the same location as the Element.xml used to create the WebTemplate, and set its deployment option to Element• Edit the Onet.xml with the appropriate Site and Web features. Remove all unnecessary components
    9. 9. WebTemplate Element Structure• <?xml version="1.0" encoding="utf-8"?>• <Elements xmlns="">• <WebTemplate• BaseConfigurationID=""• BaseTemplateID=""• BaseTemplateName=""• Name=""• Description=""• DisplayCategory=""• Title="">• </WebTemplate>• </Elements>
    10. 10. Basic Web Template
    11. 11. Demo
    12. 12. Best Practices• Create Folders for Items• Create PropertyBag and associate it with the WebTemplate• Use the Webtemp*.xml files to determine the site definition the is most like the site you are trying to create and use its “fingerprint” – WebTemp.xml file located in the %ProgramFiles%Common FilesMicrosoft Sharedweb server extensions14TEMPLATELCIDXML• Comment your features in the Onet.xml file
    13. 13. Potential Issues• WebTemplate Name is not the same as the Folder that it is in• Onet.xml deployment type not set to ElementFile• Web Templates only work with Configuration ID 0• Site Features are only activated for top level sites in a site collection
    14. 14. References• templates.aspx•• webtemplates.aspx• site-collections.aspx• Mark Collins
    15. 15. Join us right after the event here at theWoodlake Hotel for SharePint! Socialize and unwind after our day of learning.