How to: Supply a doc template for a Content Type in a Feature

So if you have played with MOSS features at all, you probably know that it is possible to deploy all kinds of customizations as features: custom actions, workflows, list definitions, content types, etc. In my demo, I wanted a feature that contained a content type for a document library to also provide a new word document "InterviewConfirmation.docx" as its template. Surprisingly, this little extra is a bit hard to find. You can easily find how to declare the content type, how to add site columns to it, and how to bind it to a list. But supply a document template. Nope. Nada. So here is a nice piece of info:

First in the feature.xml file, you need to include your element manifest where the content type is stored. And you also need an elementfile declaration for the document template:

    <ElementManifest Location="hrdocs.xml"/>
    <ElementFile Location="InterviewConfirmation.docx"/>

Then in the element manifest, the following declares a Interview Confirmation content type that derives from document (0x0101). You then use the content type's DocumentTemplate element to build the link to the file. But you need to use a module to get the file loaded into the site collection. After some exploring with SharePoint designer, you can see where these files go. They are stored in the _cts folder in a folder named the same as the content type. You can use a Module element to provision the file.

<Elements xmlns="">
  <ContentType ID="0x01010D"
               Name="Interview Confirmation"
               Group="HR Docs"
               Description="Interview Confirmation"
    <DocumentTemplate TargetName="InterviewConfirmation.docx"/>
  <Module Name="HRDocs" Url="_cts/Interview Confirmation" RootWebOnly="TRUE">
    <File Url="InterviewConfirmation.docx" Name="InterviewConfirmation.docx" Type="Ghostable"></File>