Share via


How to: Add a Document Template, File Type, and Editing Application to a Site Definition

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This programming task provides steps for customizing Windows SharePoint Services so that documents can be created or edited from a third-party application. The task involves creating a document template file to complement the Onet.xml file of the site definition, modifying the DocIcon.xml file, and creating a DLL that provides the same functionality as described for the OpenDocuments Control.

Adding the ability to create or edit documents within an application involves the following subtasks:

  • Creating a document template file, which in effect adds a DocumentTemplate to the Onet.xml file of the site definition

  • Adding a Mapping element to DocIcon.xml for a file type icon and for identification of the control to use to open the file

  • Creating a DLL that provides the necessary functions for creating or editing documents in the application

Adding a Document Template

To add an application document as a template that can be used in document libraries, you can either specify the DocumentTemplate element within a Content Type Feature (see Content Type Deployment Using Features), or specify the DocumentTemplate element within the Onet.xml file of a custom site definition (see How to: Create a Custom Site Definition and Configuration).

The following example shows how to use the DocumentTemplate element in an Onet.xml file.

<DocumentTemplates>
   <DocumentTemplate DisplayName="Blank Document" Type="105" 
      Default="FALSE" Description="A blank document.">
      <DocumentTemplateFiles>
         <DocumentTemplateFile 
            Name="doctemp/Template_Folder/psdtmp1.psd" 
            TargetName="Forms/template.psd" Default="True"/>
      </DocumentTemplateFiles>
   </DocumentTemplate>
</DocumentTemplates>

The DisplayName attribute of the DocumentTemplate element specifies the text that is displayed in the drop-down list for selecting a document template type when creating a new document library. The Type attribute uniquely identifies the document type and can be any integer that is not already used for another document template. The Default attribute specifies whether the template is selected by default in the drop-down list. The Name attribute of the DocumentTemplateFile specifies the physical path to the template file on the server computer, while the TargetName attribute specifies the address of the template relative to the document library.

Reset Microsoft Internet Information Services (IIS) for changes to take effect.

Adding a Mapping Definition for a File Type

To map a file extension to a document type, and to identify the control to use when opening a document that has the file extension, add a Mapping element to DocIcon.xml. DOCICON.XML resides in the \\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML directory.

Adding the following line within the ByExtension in DocIcon.xml maps the .psd extension to an image file named icpsd.gif, which provides the icon that is displayed in document libraries for files of this type:

<Mapping Key="psd" Value="icpsd.gif"/>

To enable editing within an application, the Mapping must also include EditText and OpenControl attributes, as follows:

<Mapping Key="psd" Value="icpsd.gif" EditText="Application" OpenControl="ProgID"/>

The EditText attribute specifies the application name that is displayed on the drop-down menu when a user clicks the Edit arrow for a document. The OpenControl attribute specifies the ProgID of the control to use for opening files of the specified type.

The image file that is specified by the Value attribute must reside in the \\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES directory. If the specified image file is missing from this directory, a "missing image" icon appears beside the document.

To prevent users from being prompted for credentials to see the icon when Anonymous Access is enabled, you must set inheritable permissions on the image file

To set inheritable permissions on the image file

  1. Right-click the referenced image file in the IMAGES folder, and then click Properties.

  2. On the Security tab in the Properties dialog box, click Advanced.

  3. On the Permissions tab in the Advanced Security Settings dialog box, ensure that the check box is selected for Allow inheritable permissions from the parent to propagate to this object and all child objects. Include these with entries specifically defined here.

Note The default size for icons in Windows SharePoint Services is 16 x 16 pixels.

Reset IIS for changes to take effect.

Adding an Editing Application

Create a DLL providing the control to load for a document of the specified type whose ProgID identifies the control, for example, SharePoint.OpenDocuments. The control that you create must provide the same methods for creating, opening, and viewing documents as described for the OpenDocuments Control.

To perform the customizations described in this topic, you must be an administrator on the front-end server running Windows SharePoint Services.

Warning

Changes that you make to originally installed files may be overwritten when you install updates or service packs for Windows SharePoint Services, or when you upgrade an installation to the next product version.