Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am attempting to specify a custom content type onto a reference library which is being provisioned in a site definition but am so far failing.

I have read:-

Deploy document library with multiple content type

Which seems to be achieving what I want to do. However it is not a thorough answer for me to see what is going on. Could someone either elaborate on the answer given i.e. what settings go into which file. Or provide some guidance on how to get this working.

at the moment i have a

  • List definition
  • 2 Features (one for the List definition and one for the List instance)
  • List Instance
  • List Schema (schema.xml)
  • Site Definition (With Onet.xml in)

my files look like the following

elements.xml (List definition)

<?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 Definition project item, an error will occur when the project is run. -->
<ListTemplate
    Name="Reference Library"
    Type="40001"
    BaseType="1"
    OnQuickLaunch="TRUE"
    SecurityBits="11"
    Sequence="410"
    DisplayName="Reference Library"
    Description="Refrence Library"
    Image="/_layouts/images/itgen.png"/>
</Elements>

elements.xml (List instance)

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="Refrence Library"
            OnQuickLaunch="TRUE"
            TemplateType="40001"
            Url="Lists/Refrence-Library"
            FeatureId="46be35ad-f023-4ba2-921d-c7fb2d5d5f7d"
            Description="Refrence Library">
  </ListInstance>
</Elements>

Schema.xml

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="Reference Library" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Reference-Library" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/" EnableContentTypes="TRUE">
  <MetaData>
<ContentTypes>
  <ContentTypeRef ID="0x010100DC427A4F89BB41BD9DEFA384EEA1CF4D" />
</ContentTypes>
<Fields></Fields>
<Views>
  <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
    <Toolbar Type="Standard" />
    <XslLink Default="TRUE">main.xsl</XslLink>
    <RowLimit Paged="TRUE">30</RowLimit>
    <ViewFields>
      <FieldRef Name="LinkTitleNoMenu"></FieldRef>
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
      </OrderBy>
    </Query>
    <ParameterBindings>
      <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
      <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
      <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
    </ParameterBindings>
  </View>
  <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
    <Toolbar Type="Standard" />
    <XslLink Default="TRUE">main.xsl</XslLink>
    <RowLimit Paged="TRUE">30</RowLimit>
    <ViewFields>
      <FieldRef Name="ID"></FieldRef>
    </ViewFields>
    <Query>
      <OrderBy>
        <FieldRef Name="ID"></FieldRef>
      </OrderBy>
    </Query>
    <ParameterBindings>
      <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
      <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
    </ParameterBindings>
  </View>
</Views>
<Forms>
  <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>

Site Definition (Onet.xml)

<?xml version="1.0" encoding="utf-8"?>
<Project Title="NewsPortal" Revision="2" ListDir="" xmlns:ows="Microsoft SharePoint" xmlns="http://schemas.microsoft.com/sharepoint/">
 <NavBars>

 </NavBars>
<Configurations>
  <Configuration ID="0" Name="NewsPortal">
  <SiteFeatures>
      <!--Provisioning //-->
      <Feature ID="6b0edd82-42c5-44fc-af72-041c793e227c" />
      <!--Ref Lib LIST DEF//-->
      <Feature ID="46be35ad-f023-4ba2-921d-c7fb2d5d5f7d" />
      <!--News LIST DEF//-->
      <Feature ID="599cdcf2-afdd-4ee8-a786-500554fc2b82" />
      <!--CONTENT TYPES//-->
      <Feature ID="8cacd2e9-f4cc-4d70-ba95-a77b3ecb3e0e" />
      <!--BRANDING//-->
      <Feature ID="8ab2f14a-ef0b-4d1a-8dc7-b38ff8dc5001" />
      <!--News Roatator //-->
      <Feature ID="45526575-ea6b-45ce-8f1c-7de5b5f6fc6c" />
  </SiteFeatures>
  <WebFeatures>
      <!-- Ref Lib LIST INSTANCE //-->
      <!--<Feature ID="547d096c-4916-4abf-8366-aafe68cf9274" />//-->
      <!-- News LIST INSTANCE //-->
      <Feature ID="241b1c4b-a7d0-4403-ac58-eb451343af29" />
      <!-- IMAGE LIBRARY //-->
      <Feature ID="00BFEA71-52D4-45B3-B544-B1C71B620109" > </Feature>
      <!--Document Library-->
      <Feature ID="00BFEA71-E717-4E80-AA17-D0C71B360101" > 

      </Feature>
      <!-- INHERIT PARENT NAVIGATION-->
      <Feature ID="541F5F57-C847-4e16-B59A-B31E90E6F9EA">
          <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
              <Property Key="InheritGlobalNavigation" Value="true"/>
              <Property Key="ShowSiblings" Value="true"/>
              <Property Key="IncludeSubSites" Value="true"/>
          </Properties>
      </Feature>
  </WebFeatures>
  <Modules>
    <Module Name="DefaultBlank" />
    <Module Name="PostPage" />
  </Modules>
</Configuration>
 </Configurations>
  <Modules>
   <Module Name="DefaultBlank" Url="" Path="">
      <File Url="default.aspx">
      <View List="Lists/NewsItemsListInstance" BaseViewID="2" WebPartZoneID="left" WebPartOrder="2">
          <![CDATA[
                    <webParts>
                        <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                            <metaData>
                                <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
                                <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                            </metaData>
                            <data>
                                <properties>
                                    <property name="AllowConnect" type="bool">True</property>
                                    <property name="ChromeType" type="chrometype">None</property>
                                    <property name="AllowClose" type="bool">False</property>
                                </properties>
                            </data>
                        </webPart>
                    </webParts>
                ]]>
      </View>
      <AllUsersWebPart WebPartZoneID="feature" WebPartOrder="1">
          <![CDATA[
          <webParts>
              <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                <metaData>
                  <type name="inSightDevelopmentProject.GCVWPNewsFeatureRotator.GCVWPNewsFeatureRotator, inSightDevelopmentProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4993002641328269" />
                  <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                </metaData>
                <data>
                  <properties>
                    <property name="Title" type="string">GCVWPNewsFeatureRotator</property>
                    <property name="Description" type="string">My Visual WebPart</property>
                    <property name="ChromeType" type="chrometype">None</property>
                    <property name="_NewsItemsListName" type="string">News Items List</property>
                    <property name="ExportMode" type="exportmode">All</property>
                  </properties>
                </data>
              </webPart>
          </webParts>
        ]]>
      </AllUsersWebPart>
      <AllUsersWebPart WebPartZoneID="right" WebPartOrder="3">
          <![CDATA[
                        <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
                         <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                         <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
                         <Title>Latest Forum Discussions</Title>
                         <Description>Allows authors to enter rich text content.</Description>
                         <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
                         <FrameType>TitleBarOnly</FrameType>
                        </WebPart>
    ]]>
      </AllUsersWebPart>
      <AllUsersWebPart WebPartZoneID="right" WebPartOrder="2">
          <![CDATA[
                        <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
                         <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                         <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
                         <Title>Systems Down</Title>
                         <Description>Allows authors to enter rich text content.</Description>
                         <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
                         <FrameType>TitleBarOnly</FrameType>
                        </WebPart>
    ]]>
      </AllUsersWebPart>
      <AllUsersWebPart WebPartZoneID="right" WebPartOrder="1">
          <![CDATA[
                        <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
                         <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                         <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
                         <Title>Latest Announcements</Title>
                         <Description>Allows authors to enter rich text content.</Description>
                         <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
                         <FrameType>TitleBarOnly</FrameType>
                        </WebPart>
    ]]>
      </AllUsersWebPart>
  </File>

</Module>
<Module Name="PostPage" Url="" Path="">
  <File Url="NewsPost.aspx">
      <View List="Lists/NewsItemsListInstance" BaseViewID="3" WebPartZoneID="left" WebPartOrder="1">
          <![CDATA[        
               <webParts>
                        <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                            <metaData>
                                <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
                                <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                            </metaData>
                            <data>
                                <properties>
                                    <property name="AllowConnect" type="bool">True</property>
                                    <property name="ChromeType" type="chrometype">None</property>
                                    <property name="AllowClose" type="bool">False</property>
                                </properties>
                            </data>
                        </webPart>
                    </webParts>
          ]]>
      </View>       
  </File>
</Module>
  </Modules>
</Project>

Any help Guidance would be greatly appreciated.

Thanks

Nicholas

share|improve this question
add comment

2 Answers 2

It would be nice to know which kind of problems you experience.

But at Least I can see following possible issues:

  • It seems as if you don't define Site Columns and ContentType before List Definition
  • You're missing listing all the FieldRefs in Schema.xml
share|improve this answer
    
Sorry Per, no tangible sharepoint error that appears, just that the library does not adopt the content type that i specify (when i check to see what content type has been specified as being managed by the library in the GUI, it states a fictitious one called refrence library is being managed in it). All the content type have been created and exist in sharepoint already, which is why im not recreating them in schema.xml. I have a method and have managed to get this working while provisioning lists, but doing it with librarys does not seem to work :-(. Thanks for your answer.Any other ideas? –  Nicholas King Aug 30 '12 at 8:11
add comment
up vote 0 down vote accepted

i have ammended my list instance (elements.xml)

to include a content type binding and it seems to work now.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <ListInstance Title="Refrence Library"
            OnQuickLaunch="TRUE"
            TemplateType="40001"
            Url="Lists/Refrence-Library"
            FeatureId="46be35ad-f023-4ba2-921d-c7fb2d5d5f7d"
            Description="Refrence Library">
 </ListInstance>
<ContentTypeBinding
ContentTypeId="0x010100DC427A4F89BB41BD9DEFA384EEA1CF4D"
ListUrl="Lists/Refrence-Library"
/>
</Elements>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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