Creating Web Templates for SharePoint 2010

16
Mark Collins Senior SharePoint Consultant Kiefer Consulting

description

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

Transcript of Creating Web Templates for SharePoint 2010

Page 1: Creating Web Templates for SharePoint 2010

Mark CollinsSenior SharePoint ConsultantKiefer Consulting

Page 2: Creating Web Templates for SharePoint 2010

How can sites be created?

• Site Definitions• Feature Stapling• Site Templates• Custom Code• Provisioning Providers• Web Templates

Page 3: Creating Web Templates for SharePoint 2010

Method PRO CON

Site Definition Powerful method for site creation – only way to create customized sites in 2007

• Farm Level Solution• Can’t be changed once a site has been built

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 existing

Site Templates • Easy to create using the UI• Can be stored off and

modified using Visual Studio

• Do not work with publishing features enabled• Only available in site collection where created

unless exported to Visual Studio and deployed

Web Templates • Can be deployed as farm or 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 Studio

• Does not support variations

Provisioning Providers

• Flexible code based system • Require WebTemp*.xml on file system so are generally not supported by Cloud systems

• Potential to be deprecated

Page 4: Creating Web Templates for SharePoint 2010

XMLElements.xml

14\Template\Feature\<Feature Folder>

XML 14\Template\Feature\<Feature Folder>Onet.xml

XML

14\Template\Feature\<Feature Folder>

features.xml

14\Template\SiteTemplates\<base>

XMLOnet.xml

1

2

3

4

Page 5: Creating Web Templates for SharePoint 2010

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)

Page 6: Creating Web Templates for SharePoint 2010

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

Page 7: Creating Web Templates for SharePoint 2010

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)

Page 8: Creating Web Templates for SharePoint 2010

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

Page 9: Creating Web Templates for SharePoint 2010

WebTemplate Element Structure• <?xml version="1.0" encoding="utf-8"?>• <Elements xmlns="http://schemas.microsoft.com/sharepoint/">• <WebTemplate• BaseConfigurationID=""• BaseTemplateID=""• BaseTemplateName=""• Name=""• Description=""• DisplayCategory=""• Title="">• </WebTemplate>• </Elements>

Page 10: Creating Web Templates for SharePoint 2010

Basic Web Template

Page 11: Creating Web Templates for SharePoint 2010

Demo

Creating a Web TemplateIn Visual Studio

Page 12: Creating Web Templates for SharePoint 2010

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 Files\Microsoft

Shared\web server extensions\14\TEMPLATE\LCID\XML

• Comment your features in the Onet.xml file

Page 13: Creating Web Templates for SharePoint 2010

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

Page 14: Creating Web Templates for SharePoint 2010

References• http://blogs.msdn.com/b/vesku/archive/2010/10/14/sharepoint-2010-and-web-

templates.aspx• http://www.chakkaradeep.com/post/Web-Templates-and-Publishing-Sites.aspx• http://sharepointchick.com/archive/0001/01/01/site-definitions-vs.-

webtemplates.aspx• http://sharepointchick.com/archive/2011/02/10/using-web-templates-to-create-

site-collections.aspx

• Mark Collins [email protected]

Page 15: Creating Web Templates for SharePoint 2010

Thanks to Our Sponsors

Page 16: Creating Web Templates for SharePoint 2010

Join us right after the event here at the Woodlake Hotel for SharePint! Socialize and

unwind after our day of learning.

Don’t Forget SharePint

Thank you for joining us Today!