1

I have created a custom content type that inherits from the Basic Page content type.

I want to create a custom ListTemplate that will store pages, the library must use my custom content type I created above.

I have run through the ListTemplate wizard in visual studio, and deployed everything with no issues, but when I try to create a library from my listTemplate SharePoint falls over, but if I create a std document library and then add my custom content type to this library and remove the default document one, it works fine and I am able to add pages and capture the required metadata I want.

I am obviously doing something wrong with my list definition in Visual Studio. I can't find any examples on how to do what I am trying. Can anyone help me out with this?

My elements.xml for my content type and list below:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List project item, an error will occur when the project is run. -->
    <ListTemplate
        Name="SPX News Pages"
        Type="10001"
        BaseType="1"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="110"
        DisplayName="SPX News Pages"
        Description="My List Definition"
        Image="/_layouts/15/images/itdl.png"
        DocumentTemplate="121"/>
</Elements>

?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Basic Page (0x010109) -->
  <ContentType ID="0x010109005EFD25437F0A49ABB7CC25CCE1899773" Name="SPX News Content Type" Group="The SharePoint Experience" Description="Create news articles, these will be detected by the news web part." Inherits="TRUE" Version="0">
    <FieldRefs>
      <FieldRef ID="{ea3a5ffe-cb52-4abf-97f6-ecad02f4023f}" DisplayName="News Blurb" Required="TRUE" Name="News Blurb" />
      <FieldRef ID="{8e316ae1-4134-4ef9-9835-2f38ee19623c}" DisplayName="News Category" Required="TRUE" Name="News Category" />
      <FieldRef ID="{a3825c89-1ddb-4d6c-9e85-7bf5594c514f}" DisplayName="Featured Image" Required="TRUE" Name="Featured Image" />
    </FieldRefs>
  </ContentType>
</Elements>
  • Why are you creating your own Library.. you should just the add your custom content type to default Pages library (activating the Publishing feature).. Please post the Elements.xml file for your List Definition and content type – Arsalan Adam Khatri Jul 12 '14 at 15:04
  • I am creating my own library as the client's requirements are to be able to add this library from the "add an app" page, they want it to be simple for their administrators. I have put the elements in my original post. – MrThirsty Jul 12 '14 at 16:54
1

I have tried this. It is working fine. Please check the followings:
Elements.XML

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field ID="{58CA5957-14FA-450A-BE5C-A7C396DCC757}" Type="Text" Name="News Blurb" DisplayName="News Blurb" Required="TRUE" Sealed="TRUE"/>
  <Field ID="{58EB7C0A-A435-43D6-92F9-F27825000697}" Type="Text" Name="News Category" DisplayName="News Category" Required="TRUE" Sealed="TRUE"/>
  <Field ID="{D6FFD808-22E0-4EA6-A6F9-E93985C2606F}" Type="Text" Name="Featured Image" DisplayName="News Category" Required="TRUE" Sealed="TRUE"/>
  <ContentType ID="0x010109005F4BA9266BC74794AC3DAF6B2B521B50" Name="SPX News Content Type" Group="The SharePoint Experience" Description="Create news articles, these will be detected by the news web part.">
    <FieldRefs>
      <FieldRef ID="{58CA5957-14FA-450A-BE5C-A7C396DCC757}" />
      <FieldRef ID="{58EB7C0A-A435-43D6-92F9-F27825000697}" />
      <FieldRef ID="{D6FFD808-22E0-4EA6-A6F9-E93985C2606F}" />
    </FieldRefs>
  </ContentType>
    <!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List project item, an error will occur when the project is run. -->
    <ListTemplate
        Name="SPExpLibrary"
        Type="10013"
        BaseType="1"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="110"
        DisplayName="SPExpLibrary"
        Description="My List Definition"
        Image="/_layouts/15/images/itdl.png"
        DocumentTemplate="121"/>
</Elements>

Schema.XML:

<ContentTypes>
      <ContentTypeRef ID="0x010109005F4BA9266BC74794AC3DAF6B2B521B50" />
    </ContentTypes>


<Fields>
      <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" ShowInNewForm="FALSE" ShowInFileDlg="FALSE" DisplayName="$Resources:core,Title;" Sealed="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title"></Field>
      <Field ID="{4b1bf6c6-4f39-45ac-acd5-16fe7a214e5e}" Type="Text" Name="TemplateUrl" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Template_Link;" XName="TemplateUrl" Filterable="TRUE" Sortable="TRUE" Hidden="TRUE" FromBaseType="TRUE" PITarget="mso-infoPathSolution" PIAttribute="href" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="TemplateUrl"></Field>
      <Field ID="{cd1ecb9f-dd4e-4f29-ab9e-e9ff40048d64}" Type="Text" Name="xd_ProgID" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Html_File_Link;" XName="ProgID" Filterable="TRUE" Sortable="TRUE" Hidden="TRUE" FromBaseType="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="xd_ProgID"></Field>
      <Field ID="{fbf29b2d-cae5-49aa-8e0a-29955b540122}" Type="Boolean" Group="_Hidden" Name="xd_Signature" DisplaceOnUpgrade="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="xd_Signature" DisplayName="$Resources:core,Xml_signed;" XName="{FBF29B2D-CAE5-49aa-8E0A-29955B540122}" Filterable="TRUE" Sortable="TRUE" Sealed="TRUE" Hidden="TRUE" FromBaseType="TRUE" ReadOnly="TRUE"></Field>
      <Field ID="{e52012a0-51eb-4c0c-8dfb-9b8a0ebedcb6}" ReadOnly="TRUE" Type="Computed" Name="Combine" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Merge;" Filterable="FALSE" Sortable="FALSE" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Combine">
        <FieldRefs>
          <FieldRef Name="FSObjType" Key="Primary" />
          <FieldRef Name="EncodedAbsUrl" />
          <FieldRef Name="TemplateUrl" />
        </FieldRefs>
      </Field>
      <Field ID="{5d36727b-bcb2-47d2-a231-1f0bc63b7439}" ReadOnly="TRUE" Type="Computed" Name="RepairDocument" DisplaceOnUpgrade="TRUE" DisplayName="$Resources:core,Relink;" Filterable="FALSE" Sortable="FALSE" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="RepairDocument">
        <FieldRefs>
          <FieldRef Name="FSObjType" Key="Primary" />
          <FieldRef Name="ID" />
        </FieldRefs>
      </Field>
      <Field ID="{58CA5957-14FA-450A-BE5C-A7C396DCC757}" Type="Text" Name="NewsBlurb" DisplayName="News Blurb" Required="TRUE" Sealed="TRUE"/>
      <Field ID="{58EB7C0A-A435-43D6-92F9-F27825000697}" Type="Text" Name="NewsCategory" DisplayName="News Category" Required="TRUE" Sealed="TRUE"/>
      <Field ID="{D6FFD808-22E0-4EA6-A6F9-E93985C2606F}" Type="Text" Name="FeaturedImage" DisplayName="News Category" Required="TRUE" Sealed="TRUE"/>
    </Fields>


 <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,All_Documents;" DefaultView="TRUE" MobileView="True" MobileDefaultView="True" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/15/images/dlicon.png?rev=23" Url="Forms/AllItems.aspx">
            <Toolbar Type="Standard" />
            <XslLink Default="TRUE">main.xsl</XslLink>
            <JSLink>clienttemplates.js</JSLink>
            <RowLimit Paged="TRUE">30</RowLimit>
            <ViewFields>
              <FieldRef Name="DocIcon"></FieldRef>
              <FieldRef Name="LinkFilename"></FieldRef>
              <FieldRef Name="Modified"></FieldRef>
              <FieldRef Name="Editor"></FieldRef>
              <FieldRef Name="News Blurb"></FieldRef>
              <FieldRef Name="News Category"></FieldRef>
              <FieldRef Name="Featured Image"></FieldRef>
            </ViewFields>
            <ParameterBindings>
              <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noitemsinview_doclibrary)" />
              <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noitemsinview_doclibrary_howto2)" />
            </ParameterBindings>
            <Query>
              <OrderBy>
                <FieldRef Name="FileLeafRef" />
              </OrderBy>
            </Query>
          </View>

Please check the following reference as well:
http://msdn.microsoft.com/en-us/library/gg276355(v=office.14).aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.