2012-01-16 88 views
2

我已經定義了一個內容類型「相關鏈接」並設置了Inherits =「False」並添加了一行以刪除開箱即用的「標題」字段因爲我不希望它在視圖或新/編輯/顯示形式中顯示,請參閱下面CAML中的(選項1)。內容類型列表中不顯示字段Inherits =「False」

<?xml version="1.0" encoding="utf-8"?> 
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 

    <!-- ===== Fields ===== --> 
    <!-- Link Category --> 
    <Field DisplayName="Link Category" 
      Name="LinkCategory" 
      ID="{654EAC00-342B-4176-9D91-613AD724F684}" 
      Group="Custom" 
      Overwrite="True" 
      Type="Lookup" 
      ShowField="Title" 
      List="Lists/LinkCategoryList" 
      WebId="~sitecollection" /> 

    <!-- ===== Content Type ===== --> 
    <!-- 
    Related Links 
    - Parent ContentType: Item (0x01) 
    --> 
    <ContentType Name="Related Links" 
       ID="0x0100c11a1db14e564574bc49a2aa9bf325d3" 
       Group="Custom" 
       Description="" 
       Inherits="False" 
       Version="0"> 
     <FieldRefs> 
      <!-- Title (OPTION 1) --> 
      <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" /> 
      <!-- (OPTION 2) 
      <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" 
         Hidden="TRUE" Required="FALSE" DisplayName="_hidden" /> 
      --> 
      <!-- Link Category --> 
      <FieldRef DisplayName="Link Category" 
         Name="LinkCategory" 
         ID="{654EAC00-342B-4176-9D91-613AD724F684}" 
         Required="True" /> 
     </FieldRefs> 
    </ContentType> 

</Elements> 

這並從內容類型中刪除「標題」字段,但是當我試圖將內容類型與列表關聯不視圖或新建/編輯/顯示形式顯示「LinkCategory」字段。爲什麼這樣?

<?xml version="1.0" encoding="utf-8"?> 
<List xmlns:ows="Microsoft SharePoint" 
     Title="Related Links" 
     FolderCreation="FALSE" 
     Direction="$Resources:Direction;" 
     Url="Lists/RelatedLinksListDefinition" 
     BaseType="0" 
     EnableContentTypes="True" 
     xmlns="http://schemas.microsoft.com/sharepoint/"> 
    <MetaData> 
     <ContentTypes> 
      <!-- Related Links --> 
      <ContentTypeRef ID="0x0100c11a1db14e564574bc49a2aa9bf325d3" /> 
     </ContentTypes> 
     <Fields> 
     </Fields> 
     <Views> 
      <View ...etc...> 
       <ViewFields> 
        <FieldRef Name="LinkCategory"></FieldRef> 
       </ViewFields> 
       <Query> 
        <OrderBy> 
         <FieldRef Name="ID"></FieldRef> 
        </OrderBy> 
       </Query> 
      </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> 

由於各地我已經在內容類型設置繼承=「真」,並在內容類型CAML使用(OPTION 2)和隱藏的「標題」字段,但真的想了解什麼是工作去這裏,最好的方法是什麼。提前致謝!

PS:這篇文章有類似的問題:SharePoint 2010: RemoveFieldRef and Inherits="TRUE"

PSS:當我通過SP經理2010瀏覽使用選項1部署後,我得到如下:

  • '鏈接類別' 字段正確創建
  • 「相關鏈接」與「連接類別」字段正確創建內容類型
  • 「相關鏈接」列表與「相關鏈接」相關的內容類型創建
  • 但是「相關鏈接」列表沒有提及「鏈接類別」字段。

回答

1

好了,所以對我的方式沿着花園小徑......

爲什麼「鏈接類別」字段沒有被在「相關鏈接」列表上的創建是不相關的設置繼承問題= 「False」,這是因爲我沒有在列表模式中定義它,即使我已經在內容類型中定義了它。這裏提到:

http://msdn.microsoft.com/en-us/library/aa543576.aspx

當SharePoint基金會創建一個列表實例,它僅包括 那些在列表模式列表或 的基本類型模式中聲明的那些列。如果您在列表 架構中引用了站點內容類型,並且該內容類型引用了列表的基本類型架構或列表架構中包含的不是 的站點列,則不包括這些列。您必須在 列表架構中爲SharePoint Foundation聲明這些列以將其包含在列表中。

在這裏:

http://stefan-stanev-sharepoint-blog.blogspot.com/2010/03/contenttypebinding-vs-contenttyperef.html

它一個醜陋的事情是,你指定要 連接到列表中基於該列表定義,但框架 沒有按網站內容類型如果內容類型中的字段在列表中缺少 - 因此您需要在列表模式文件的Fields元素中手動添加所有內容類型的字段 。其實,這就是我所謂的 領域重新定義問題......

所以重複字段從內容類型定義以下元素列表架構:

<Fields> 
     <Field DisplayName="Link Category" 
       Name="LinkCategory" 
       ID="{654EAC00-342B-4176-9D91-613AD724F684}" 
       Group="Custom" 
       Overwrite="True" 
       Type="Lookup" 
       ShowField="Title" 
       List="Lists/LinkCategoryList" 
       WedId="~sitecollection" /> 
    </Fields> 

我可以證實,使用繼承=」假「& <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" />會刪除標題字段。

對於那些絆倒這篇文章的人來說,這裏有另一個關於Inherits =「False」的好鏈接。

https://sharepoint.stackexchange.com/questions/2995/mysteries-of-the-contenttype-inherits-attribute

+0

將此問題標記爲答案!非常感謝! – HW90 2012-05-30 06:27:24

相關問題