Working with Templates in SharePoint

  • May 8, 2009
  • By Joydip Kanjilal
  • More Articles »

Creating List Templates

A list template is a file that includes specific design information for a list, such as the columns and fields in the list, the views, and optionally, the list content. Windows SharePoint Services includes a number of list templates by default, but you can create a new template from an existing list. The process to create a list template is almost exactly the same as the process to create a site template; follow these steps:


Figure 3. Creating a List Template: The figure shows the dialog to save an existing list as a template.
  1. From Central Administration, select the list you want to save as a template.
  2. Click on Modify settings and columns.
  3. Click on the “Save list as template” option (see Figure 3).
  4. Type in the filename to use for the template file.
  5. Specify the title and description (optional) for the template.
  6. Optionally, select the "Include content" check box to include the existing list content
  7. Click OK to finish the process

 

Modifying or Deleting a List Template

To modify or delete a list template from the site template gallery, follow these steps:

  1. Click on Site Settings .
  2. Switch to Site Administration.
  3. Click on "Manage list template gallery."
  4. Click on the Edit button next to the list template you want to modify or delete.

To add a template to the central template gallery so that it is available to all sites in your SharePoint portal, you can use the following command (all on one line):

stsadm.exe -o addtemplate -filename NameoftheTemplateFile 
   -title TemplateTitle -description TemplateDescription

Create a Custom Site Template

Usually, you copy a template so you can customize it to control the look and feel of the pages in your web sites. To create a custom site template in SharePoint, follow these steps:

  1. Copy the SPS folder from the location C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033.
  2. Save the folder somewhere else, renaming it to SPSDevXCustom for this example.
  3. Open the Default.aspx file from the new SPSDevXCustom folder, and modify it as shown below:
  4. <WebPartPages:WebPartZone runat="server" 
      AllowPersonalization="false" 
      ID="DevXZone" 
      Title="DevX Custom Zone" 
      Orientation="Vertical">
    </WebPartPages:WebPartZone>
  5. Now open the onet.xml file from the SPSDevXCustom\XML folder, and change the <AllUsersWebPart> tag as shown below:
  6. <AllUsersWebPart WebPartZoneID="DevXZone" 
       WebPartOrder="0">
       <![CDATA[
         <WebPart xmlns=
          "http://schemas.microsoft.com/WebPart/v2">
          <Assembly>DevX, Version=1.0.0.0,Culture=Neutral, 
            PublicKeyToken=1111111111111111</Assembly>
            <TypeName>DevX.WebParts</TypeName>
            <Title>DevX Web Part</Title>
            <Description>This is a Custom Web Part</Description>
            <PartOrder>0</PartOrder>
            <FrameType>None</FrameType>
            <AllowMinimize>true</AllowMinimize>
            <AllowRemove>true</AllowRemove>
            <IsVisible>true</IsVisible>
            <AllowOverrideGlobalXML 
              xmlns="DevX">false</AllowOverrideGlobalXML>
         </WebPart>]]>
    </AllUsersWebPart>
  7. Next, open the webtempsps.xml from the SPSDevXCustom\XML folder, which looks like this:
  8. <Templates>
      <Template Name="SPSTOC" ID="30">
        <Configuration ID="0"
          Title="Contents area Template" Type="0"
          Hidden="TRUE" 
          ImageUrl="../images/spshome.gif"
          Description="Area Template.">
          <!-- _locID@Title="webtemp_title_spstoc0" 
              _locComment="{StringCategory=HTX}" -->
          <!--_locID@Description="webtemp_desc_spstoc0" 
              _locComment="{StringCategory=HTX}"-->
        </Configuration>
      </Template>  
    </Templates>
  9. Change the <Template> section as shown below:
  10. <Templates>
      <Template Name="<code> SPSDevXCustom</code> " ID="9999">
      <Configuration ID="0" 
        Title="DevX Custom Template" Type="0" 
        Hidden="TRUE"     ImageUrl="../images/spshome.gif" 
        Description="This is a sample template
      </Configuration>
    </Template>
    
  11. Lastly, reset Internet Information Services (IIS) by typing iisreset at the command prompt.

That completes the operation to create a custom site template. You should now be able to see the new custom template when you log in to SharePoint Portal Server as the site administrator.

For more information, see these links:

TAGS:

Microsoft, portal, SharePoint, Web sites
12


Networking Solutions







Partners