我已經定義了一個內容類型「相關鏈接」並設置了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部署後,我得到如下:
- '鏈接類別' 字段正確創建
- 「相關鏈接」與「連接類別」字段正確創建內容類型
- 「相關鏈接」列表與「相關鏈接」相關的內容類型創建
- 但是「相關鏈接」列表沒有提及「鏈接類別」字段。
將此問題標記爲答案!非常感謝! – HW90 2012-05-30 06:27:24