This project is read-only.

Using the Central Template Gallery

The Partner Portal application uses a site template when it creates an incident sub-site within a partner’s site collection. Each partner’s site collection needs to access the incident site template. Site templates that need to be globally accessible are installed in the central template gallery (sometimes called the global template gallery). The template title must be unique within the central template gallery. The only way to add a template to the gallery is through the STSADM addtemplate command. For more information seeCustom Site Templates in the product documentation. The following code demonstrates how we add the incident site template to the central site template gallery.

stsadm -o addtemplate -filename "incidentsubsite.stp" -title "SPGSubsiteTemplate" -description "SPG Sub Site Template "

To modify the template in the central site template gallery, delete the original template and replace it with the updated version. If you want to retain the original template and also add an updated template, then you must provide a unique title and file name for the updated template when adding the new version. The following example shows how to add a second version of the original template as a new template in the central site template gallery:

stsadm -o addtemplate -filename "incidentsubsiteV2.stp" -title "SPGSubsiteTemplateV2" -description "SPG Sub Site Template V2"

This example adds the updated version as a new template for the incidentsubsite template to the gallery. Notice that both the name and title differ from the original template. This approach leaves both the original and new template available for use.

Viewing the Gallery Contents

There are two ways to view the template gallery to discover the global site templates that are available. You can either use the browser to create a site or you can use the STSADM Enumtemplates command.
To use the browser, navigate to the root of your site collection. Click the Site Actions tab and select Create from the drop-down list. Click the Sites and Workspaces link. The new SharePoint Web site page opens. In the template selection area, you will see a Custom tab if there are any custom templates installed in the gallery. Click Custom to display the list of available templates. Only the titles of the templates appear in the list.
Figure xx illustrates the template selection area and the Custom tab.
central template gallery.png
Figure xx
Template Selection AreaYou can also use the Enumtemplates command to list the templates in the gallery. The following code shows how to do this.

stsadm -o enumtemplates

The following is a sample response.

SPGSubsiteTemplate - Language: 1033 - Site Template: _GLOBAL_#0 - Template Id: 1
SPGSubsiteTemplateV2 - Language: 1033 - Site Template: _GLOBAL_#1 - Template Id: 1
MyOtherSiteTemp - Language: 1033 - Site Template: _GLOBAL_#2 - Template Id: 1

The Enumtemplates command provides more information than the browser. It includes the language, where 1033 is American English, a global identifier that SharePoint uses and the template ID.
If you use the Addtemplate command, you must update any references in your code to point to the updated template with the new name. MOSS does not recognize the updated template as a replacement for the original template. See Mapping a Site to a Global Site Template later in this topic to learn how to remap your references.
An alternative to renaming the updated template is to first delete the original template and then add the updated template. The following code demonstrates how to do this.

stsadm -o deletetemplate -title SPGSubsiteTemplate
stsadm -o addtemplate -filename "incidentsubsite.stp" -title "SPGSubsiteTemplate" -description "SPG Sub Site Template"

The first STSADM command deletes the site template with the title SPGSubsiteTemplate. The second command adds the updated version of the template. Because the file name and title are the same as the original template, there is no need to update the references to the template.

Last edited May 28, 2009 at 8:34 PM by ckeyser, version 2


No comments yet.