Provision a Content Type with a Document Template using a Feature – Part 1


Provisioning a SharePoint Content Type using a feature is straightforward enough, whats not so well documented is configuring the content type to have a custom document template. But, actually this too is pretty easy.

Along the way I’ve found these blogs pretty useful;

Background.

You can configure a Content Type to have a custom document template using the UI as shown;

Configure content types document template

The second option allows you to upload a template which will be stored in SharePoint in a folder called _cts/{content type name}. If you use SharePoint Designer you’ll see this folder in the root of your site/site collection. The first option allows you to specify a URL to the document template to use.

If you specify just the document template name as the URL, as shown above, SharePoint assumes the document template is stored in the _cts/{content type name} folder, and will attempt to load it from there. This is what the second option actually does, it uploads the document template to the _cts/{content type name} folder and sets the URL of the template to the template filename.

You can however use the first option to set the URL of the template to be a full, server relative URL of an existing template, as shown below.

Configure content type document template using full URL

Whats the difference you ask? Well for most people there is no difference at all except in the way you provision the document templates themselve (using a feature) – more on that in Part 2. However based on my own experience a difference becomes apparent when you start using multiple content types inside a single document library.

In this scenario, when you select a specific content type from the New drop down menu;  the Office client loads using the correct template but doesn’t save the document back to SharePoint using the content type you selected, instead using the default content type of the document library. This problem and a possible solution is described by Nick Grattan in this post. While the solution is a good one, it’s difficult to provision using a Feature.

Another, curious, observation I’ve found concerns the location and therefore the URL of the document template configured against the content type.

I mentioned previously that the document template could be a full, server relative URL, and in my example (the Function Sample content type) the location of the template was in the _layouts folder. In this scenario, the behaviour I’ve seen is this;

Selecting New -> Function Sample from SharePoint, opens Word using the correct document template. So far this is normal behaviour. When saving though, Word displays a dialog box allowing you to choose which Content Type the document is to be saved as;

Choosing the Content Type from the Word client

I have no idea why this seems to be the case, but in my environment, it’s at least consistent.

In Part 2, I’ll demonstrate how content types with document templates can be provisioned.

Published by

Phil Harding

SharePoint Consultant, Developer, Father, Husband and Climber.

3 thoughts on “Provision a Content Type with a Document Template using a Feature – Part 1

  1. I am encountering exactly the same problems and is is great to find a blog that deals with this. I hope it will be helpfull

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.