开发者

ContentType DocumentTemplate not found in a List

开发者 https://www.devze.com 2022-12-23 17:54 出处:网络
I have the following Feature: <?xml version=\"1.0\" encoding=\"utf-8\"?> <Feature Id=\"9A3C5D02-A2EB-4725-97F7-CDA6DE319F1B\"

I have the following Feature:

<?xml version="1.0" encoding="utf-8"?>
<Feature Id="9A3C5D02-A2EB-4725-97F7-CDA6DE319F1B"
   开发者_StackOverflow社区 Title="My Custom Types"
    Scope="Site"
    DefaultResourceFile="core"
    Hidden="TRUE"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <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/">
    <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?


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.


I had the same exact problem with document template for List Content Type.

What I did is just what SharePoint do when you create your library from web site : duplicate the document template inside the “Forms” folder of the library in a subfolder that have the same name than the content type.

You just need to add a module element somewhere in your project :

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="MeetingMinutesListInstanceTemplate" Url="Shared Documents/Meeting Minutes" Path="templates" RootWebOnly="TRUE">             
    <File Url="MeetingMinutes.docx" Type="Ghostable" />
  </Module>
</Elements>

It worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消