- Provision a Content Type with a Document Template using a Feature – Part 1.
- Provision a Content Type with a Document Template using a Feature – Part 2.
In this post we’ll provision a content type with a document template using a feature.
To create the feature we’ll use Visual Studio and WSPBuilder, and we’re going to create 2 content types;
- 1 which provisions the document template into the _cts/{content type name} folder
- 1 which provisions the document template into the _layouts folder.
Before we start my project structure looks like this;
Create a standard site collection scoped feature;
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="a4c8c426-6d87-4b2f-b109-e7f00b7d6c15"
Title="My Test ContentTypes"
Description="Description for MyTestContentTypes"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Site"
DefaultResourceFile="core"
ActivateOnDefault="FALSE"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="contenttypes.xml"/>
<ElementFile Location="templates\doc1.dotx"/>
</ElementManifests>
</Feature>
Now create the contenttypes.xml manifest file;
<?xml version="1.0" encoding="utf-8" ?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <ContentType ID="0x0101002880177DFDC248c38C745E1D664A5FC5" Name="Doc Sample" Description="Test CT with DT" Group="_Custom"> <FieldRefs /> <DocumentTemplate TargetName="doc1.dotx"/> </ContentType> <Module Name="PopulateDocTemplates" Url="_cts/Doc Sample" RootWebOnly="TRUE" Path="templates" SetupPath="Features\MyTestContentTypes\templates"> <File Url="doc1.dotx" /> </Module> <ContentType ID="0x0101009889C18B0DFB4fc58C8D35C9AB4EDE03" Name="Function Sample" Description="Test CT 2 with DT" Group="_Custom"> <FieldRefs /> <DocumentTemplate TargetName="/_layouts/1033/LCFT/templates/doc2.dotx"/> </ContentType> </Elements>
* If your content type does not include any additional fields above those of the inherited content type, you must still include the empty <FieldRefs /> element.
The 1st content type (Doc Sample) provisions the document template into the _cts/Doc Sample folder using a Module.
The 2nd content type (Function Sample) provisions the document template into the file system in the _layouts/1033/LCFT/templates folder as a template file.
Build and package up the WSP, deploy and activate the feature.






My