Question

I want to create a new document library definition for general use in our SharePoint environment. This new list has some predefined content-types. Users will add this list themselves one or more times to the site they are working in (via Site Actions, Add list).

This is working fine, I've copied the OOTB DocLib definitions, renamed it and added my custom contenttype (defined in an other feature). When I create a list based on this schema/list definition the right contenttypes, and the columns are added to the new list.

The only thing missing are the templates defined for these content-types. The templates are correctly provisioned to the global _cts/myContentTypeA folder. But they are not copied to the local resources folder of the newly created list. The TargetFolders are created, empty though.

When I delete the contenttype and re-add it (all in the UI) the templates ARE copied.

What do I have to write in CAML to make this work?

Schema

<List xmlns:ows="Microsoft SharePoint" 
  Title="My DocLib" 
  EnableContentTypes="TRUE"
  FolderCreation="FALSE"
  VersioningEnabled="FALSE"
  Direction="$Resources:Direction;"
  Url="Documenten"
  BaseType="1"
  xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>
      <ContentTypeRef ID="0x010100EED05E02DB9F4831932432C1B47334B201">
        <Folder TargetName="Forms/myContentTypeA" />
      </ContentTypeRef>
      <ContentTypeRef ID="0x010100EED05E02DB9F4831932432C1B47334B202">
        <Folder TargetName="Forms/myContentTypeA" />
      </ContentTypeRef>
      <ContentTypeRef ID="0x010100EED05E02DB9F4831932432C1B47334B203">
        <Folder TargetName="Forms/myContentTypeA" />
      </ContentTypeRef>

    </ContentTypes>
    <Fields>
      ...
    </Fields>
    <Views>
      ...
    <Views>
 </List>

ListTemplate elements.xml

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListTemplate
    Name="mydoclib"
    Type="13001"
    BaseType="1"
    OnQuickLaunch="TRUE"
    SecurityBits="11"
    Sequence="111"
    Category="Libraries"
    DisplayName="My DocLib Documentbibliotheek"
    Image="/_layouts/images/itdl.gif"
    DocumentTemplate="101"
    DisallowContentTypes="False"
    FolderCreation="FALSE">
  </ListTemplate>
</Elements>

ContentType definition

<ContentType ID="0x010100EED05E02DB9F4831932432C1B47334B201"
           Name="myContentTypeA"
           Group="myGroup"
           >
  <DocumentTemplate TargetName="myContentTypeA.dotm"></DocumentTemplate>
  <Folder TargetName="_cts/myContentTypeA"></Folder>
  <FieldRefs>
    <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" DisplayName="Onderwerp"/>
    <FieldRef ID="{039DC5A3-698A-46cc-AF75-0D0B1A1718CE}" Name="Datum" />
    <FieldRef ID="{7B8E56E4-DD61-4f24-BA0E-9E728A5CC9D2}" Name="Ons Kenmerk"/>
    <FieldRef ID="{BD4903C5-E667-4184-8878-4E14F67533FD}" Name="Uw Kenmerk" />
    <FieldRef ID="{E97E2124-CECC-4666-9B42-10299C35E5D0}" Name="Adres" />
  </FieldRefs>
  <XmlDocuments>
    ...
  </XmlDocuments>
</ContentType>
<Module Name="myContentTypeA" Path="templates"
        Url="_cts/myContentTypeA" RootWebOnly="TRUE">
  <File Url="myContentTypeA.dotm" Type="Ghostable" />
</Module>

Same for others (B and C)
Was it helpful?

Solution

You also need to duplicate the template inside the folder library itself. Here is a nice artile on how to do it. Also you need to add DocumentTemplate and Folder nodes to the schema.xml in the respective content type.

Update: After reading the comments did a test and this is what worked for me.

<ContentType ID="0x0101004b60f7c3b1ba437f8853236e9bbb3903"
               Name="ListDefWithTemplate1"
               Group="Custom Content Types"
               Description="My Content Type"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
    </FieldRefs>
    <Folder TargetName="/_cts/ListDefWithTemplate1/" />
    <DocumentTemplate TargetName="Timesheet.xls" />
  </ContentType>

And in my schema, I added

<Folder TargetName="Forms/ListDefWithTemplate1" />
<DocumentTemplate TargetName="Timesheet.xls" />
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top