3.2. Creating Custom Site TemplatesTo create a custom site template:
For example, to extend the standard Team Site template to include a Picture Library:
animal 3-2. Saving a modified site as a new, custom templateCustom templates added to the Site Template Gallery appear in the templates list when you create a new site, as shown in Figure 3-3. 3.2.1. Viewing, Editing, and Deleting Template FilesThe custom template file ( .stp ) in Figure 3-2 is actually a compressed cabinet file containing an XML template description. To see the contents of the template file:
The following XML fragment shows the details portion of the manifest.xml file for the custom template created in Figure 3-2: <?xml version="1.0" encoding="UTF-8" ?> <Web Url="http://localhost/ModifiedTeamSite"> <MetaInfo> ... </MetaInfo> <Details> <TemplateDescription>Demo site template to show how easy it is to create a new template based on an existing one. </TemplateDescription> <TemplateTitle>Team Site with Picture Library</TemplateTitle> <Language>1033</Language> <TemplateID>1</TemplateID> <Configuration>0</Configuration> <Title>Modified Team Site Template</Title> <Description></Description> <CalendarType>1</CalendarType> <AlternateCSS></AlternateCSS> <CustomJSUrl></CustomJSUrl> <AlternateHeader></AlternateHeader> <Subweb>1</Subweb> <Locale>1033</Locale> <Collation>25</Collation> <TimeZone>13</TimeZone> </Details> ... </Web> To make changes to a custom template directly:
animal 3-4. Uploading a new site templateTo delete a template from the gallery, click the Edit icon next to the template name and then choose Delete from the template's description page. Deleting a custom site template doesn't affect existing sites based on that template. 3.2.2. Replacing a Predefined TemplateIt's very difficult to modify the predefined templates, and in fact Microsoft recommends that you avoid doing so, since upgrading to a new release of SharePoint would overwrite your changes and possibly break sites based on those templates. It's simpler and safer to create a new, custom template with the same name, and then hide the predefined templatein effect replacing the predefined template with your own. To replace a predefined template with a custom template:
The WebTemp.xml file is found in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\1033\XML folder of the SharePoint server. To hide a template, change the Hidden attribute to trUE , as shown here in bold : <Templates xmlns:ows="Microsoft SharePoint"> <Template Name="STS" ID="1"> <Configuration ID="0" Title="Team Site" Hidden="TRUE" ImageUrl="/_layouts/images/ stsprev.png" Description="This template creates a site for teams to create, organize, and share information quickly and easily. It includes a Document Library, and basic lists such as Announcements, Events, Contacts, and Quick Links."></Configuration> ... </Template> ... </Templates> After you restart IIS, your custom template appears in the template list, as shown in Figure 3-3, and the built-in template doesn't. SharePoint always displays the built-in templates before the custom templates, so the order of the list is changed. 3.2.3. Adding PagesWhen you create a new site template based on an existing site, SharePoint includes in the new site template any pages you added in these circumstances:
Including content with the template copies the contents of all the site's lists into the new template; so if you've stored custom pages in the Shared Documents list, they will be included in any new site based on the custom template. You can't selectively include some lists and exclude others. When including content in a template, create the template from a clean "base" site that contains only the content you want to copy into each new site. You usually won't want to include lists that represent live data in a template. For example, including Contacts data in a template creates a new copy of Contacts each time a site is created from the template. If all of your sites share a common set of Contacts, you'll want those sites to link to the same data source rather than having to maintain multiple copies of the data. 3.2.4. Changing the Built-in PagesChanges made to built-in pages, such as the home page ( default.aspx ), are copied to the new template when you create a new template based on an existing site. If you download the template file and open it with a cab-file viewer, such as WinZip, you can see the changes that the template includes, as shown in Figure 3-5. The generated file names in the template file are mapped to the web-site file names through manifest.xml . For example, the d1000000.000 file displayed in Figure 3-5 maps to default.aspx, as shown by this snippet from manifest.xml : <File Name="default.aspx" Src="d1000000.000"> <MetaInfo> ... </MetaInfo> </File> |