views:

195

answers:

1

I have the following Feature:

<?xml version="1.0" encoding="utf-8"?>
<Feature Id="9A3C5D02-A2EB-4725-97F7-CDA6DE319F1B"
    Title="My Custom Types"
    Scope="Site"
    DefaultResourceFile="core"
    Hidden="TRUE"
    xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    <ElementManifests>
        <ElementManifest Location="Elements.xml" />
        <ElementFile Location="templates/MeetingMinutes.docx" />
    </ElementManifests>
</Feature>

Which contains the following Elements.xml:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    <Module Name="Templates" Url="_cts/Meeting Minutes" Path="templates" RootWebOnly="TRUE">
        <File Url="MeetingMinutes.docx" Type="Ghostable" />
    </Module>
    <ContentType
        ID="0x01010066DD088A6B8B46BCA775CCD119FBB3E8"
        Name="Meeting Minutes"
        Group="Custom Content Types"
        Version="0">
        <FieldRefs />
        <DocumentTemplate TargetName="MeetingMinutes.docx"/>
    </ContentType>
</Elements>

I then use this ContentType within a custom List Template:

<ContentTypes>
  <ContentTypeRef ID="0x0101">
    <Folder TargetName="Forms/Document" />
  </ContentTypeRef>
  <ContentTypeRef ID="0x01010066DD088A6B8B46BCA775CCD119FBB3E8">
    <Folder TargetName="Forms/Document" />
  </ContentTypeRef>
  <ContentTypeRef ID="0x0120" />
</ContentTypes>

I deploy the solution, activate the feature, and create an instance of the List Template. I go into the library and select Settings > Document Library Settings > Content Types: Meeting Minutes > Parent: Meeting Minutes > Advanced settings. I'm now in the Advance Settings of the Site Content Type. The URL of the existing document template is MeetingMinutes.docx and there is an (Edit Template) link which points to http://myserver/sites/testsite/_cts/Meeting%20Minutes/MeetingMinutes.docx. Everything's shiny.

But, I hit the back button two times so I'm back in the settings of the List Content Type. This time when I click Advance settings, the URL of the existing document template is still MeetingMinutes.docx, but there is no (Edit Template) link. Troubling.

Pressing on, I go back to AllItems.aspx and click New > Meeting Minutes. As Word is loading, I see a little Opening dialog which says, Opening: http://myserver/sites/testsite/Shared%20Documents/Forms/Document/MeetingMinutes.docx, to which Word responds: "Word was unable to read this document. It may be corrupt."

So the Document Template works correctly in the Site Content Type (where it does me no good), but is not working in the List Content Type (where I really need it). Now, I know I could put this in _layouts, but from what I've read, _cts is the way to do it. What am I doing wrong?

+1  A: 

Rich, I'm not exactly sure what's going on because I created a feature using your feature and elements files as you specified and it works correctly for me.

There is one difference though.

When I create a new document in the library from the content type, the template url is

http://myserver/sites/testsite/Shared%20Documents/Forms/Meeting Minutes/MeetingMinutes.docx

Not

http://myserver/sites/testsite/Shared%20Documents/Forms/Document/MeetingMinutes.docx

Somehow your content type seems to be looking in the wrong folder for the template. I hope that gives you some clues.

Paul Lucas
So *that's* what Folder TargetName is for. I never fully understood that. I originally left the section from schema.xml out of the question because I didn't think it was important. I've edited the question in order to make my mistake clearer. Thanks!
Rich Bennema
Cool, I had always wondered about that too! Thanks for pointing that out.
Paul Lucas