基内容类型层次结构
上次修改时间: 2015年3月9日
适用范围: SharePoint Foundation 2010
Microsoft SharePoint Foundation 2010 包含许多内置内容类型。除了一个内容类型之外的所有内容类型都派生自其他内置内容类型,并且可在基于亲子关系的层次机构中组织这些内容类型。在层次结构的顶部是"系统"内容类型。"系统"下面接着是派生自"系统"的"项目"内容类型,而所有其他内容类型最终从"项目"内容类型派生。
下表显示内置内容类型的部分列表。
名称 |
ID |
---|---|
系统 |
0x |
项目 |
0x01 |
文档 |
0x0101 |
事件 |
0x0102 |
问题 |
0x0103 |
通知 |
0x0104 |
链接 |
0x0105 |
联系人 |
0x0106 |
消息 |
0x0107 |
任务 |
0x0108 |
工作流历史记录 |
0x0109 |
公告 |
0x0110 |
注释 |
0x0111 |
东亚联系人 |
0x0116 |
文件夹 |
0x0120 |
请注意,许多这些基本内容类型都与您可以创建的列表类型相对应。这种对应关系是设计使然。有关详细信息,请参阅默认列表内容类型。
您可以通过仔细检查某个内容类型的 ID,确定该内容类型的一系列下级。例如,请注意,源于"项目"的所有内容类型都具有以"项目"的 ID 开头的 ID。一个子内容类型的 ID 是通过在父内容类型的 ID 中追加信息构成的。有关详细信息,请参阅内容类型 ID。
有关内置内容类型的完整列表,请参阅 SPBuiltInContentTypeId 类的字段。
分配规则
三种最重要的内置内容类型分别是"项目"、"文档"和"文件夹"。这三种类型重要的原因是,SharePoint Foundation 将强制实施有关可以如何使用从它们派生的内容类型的某些规则。您可以将内容类型分配给列表项目、文档和文件夹。但是,分配给文档库的任何内容类型都必须继承自"文档"或继承自从"文档"派生的内容类型。此外,分配给列表的任何内容类型不得从"文档"派生。这两个规则不适用于"文件夹"内容类型及其衍生内容类型。文件夹可以存在于列表和文档库中。
内容类型组
内置内容类型分成了若干个组,例如"列表内容类型"、"文档内容类型"、"文件夹内容类型"和"_Hidden"。您可以通过读取服务器代码中的 SPContentType 对象的 Group 属性或客户端代码中的 ContentType 对象的相同属性,获取给定内容类型所属的组的名称。
属于"_Hidden"组的内容类型不会显示在用户界面中以供用户应用于列表或用作其他内容类型的基类型。有关详细信息,请参阅内容类型访问控制。
您可以通过查看用户界面中的"网站设置"下的"网站内容类型"库,了解可以将哪些内容类型分配给列表和库,以及如何对内容类型进行分组。您可以通过编写类似以下控制台应用程序的服务器代码,获取一个包括隐藏内容类型的更完整的清单。
using System;
using System.Collections;
using Microsoft.SharePoint;
namespace Test
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
// Create a sortable list of content types.
ArrayList list = new ArrayList();
foreach (SPContentType ct in web.AvailableContentTypes)
list.Add(ct);
// Sort the list on group name.
list.Sort(new CTComparer());
// Print a report.
Console.WriteLine("{0,-35} {1,-12} {2}", "Site Content Type", "Parent", "Content Type ID");
for (int i = 0; i < list.Count; i++)
{
SPContentType ct = (SPContentType)list[i];
if (i == 0 || ((SPContentType)list[i - 1]).Group != ct.Group)
{
Console.WriteLine("\n{0}", ct.Group);
Console.WriteLine("------------------------");
}
Console.WriteLine("{0,-35} {1,-12} {2}", ct.Name, ct.Parent.Name, ct.Id);
}
}
}
Console.Write("\nPress ENTER to continue...");
Console.ReadLine();
}
}
// Implements the Compare method from the IComparer interface.
// Compares two content type objects by group name, then by content type Id.
class CTComparer : IComparer
{
// The implementation of the Compare method.
int IComparer.Compare(object x, object y)
{
SPContentType ct1 = (SPContentType)x;
SPContentType ct2 = (SPContentType)y;
// First compare group names.
int result = string.Compare(ct1.Group, ct2.Group);
if (result != 0)
return result;
// If the names are the same, compare IDs.
return ct1.Id.CompareTo(ct2.Id);
}
}
}
当此应用程序在只有内置内容类型可用的网站上运行时,它将生成以下输出。
Site Content Type Parent Content Type ID
_Hidden
------------------------
System System 0x
Health Analyzer Rule Definition Item 0x01003A8AA7A4F53046158C5ABD98036A01D5
Health Analyzer Report Item 0x0100F95DB3A97E8046B58C6A54FB31F2BD46
Office Data Connection File Document 0x010100629D00608F814DD6AC8A86903AEE72AA
Universal Data Connection File Document 0x010100B4CBD48E029A4AD8B62CB0E41868F2B0
User Workflow Document Document 0x010107
Workflow Task Task 0x010801
Administrative Task Task 0x010802
Workflow History Item 0x0109
Person Item 0x010A
SharePointGroup Item 0x010B
DomainGroup Item 0x010C
RootOfList Folder 0x012001
Document Collection Folder Folder 0x0120D5
Document Content Types
------------------------
Document Item 0x0101
List View Style Document 0x010100734778F2B7DF462491FC91844AE431CF
Form Document 0x010101
Picture Document 0x010102
Master Page Document 0x010105
Wiki Page Document 0x010108
Basic Page Document 0x010109
Web Part Page Basic Page 0x01010901
Link to a Document Document 0x01010A
Dublin Core Columns Document 0x01010B
Folder Content Types
------------------------
Folder Item 0x0120
Discussion Folder 0x012002
Summary Task Folder 0x012004
Group Work Content Types
------------------------
Circulation Item 0x01000F389E14C9CE4CE486270B9D4713A5D6
New Word Item 0x010018F21907ED4E401CB4F14422ABC65304
Resource Item 0x01004C9F4486FBF54864A7B0A33D02AD19B1
Official Notice Item 0x01007CE30DD1206047728BAFD1C39A850120
Phone Call Memo Item 0x0100807FBAC5EB8A4653B8D24775195B5463
Holiday Item 0x01009BE2AB5291BF4C1A986910BD278E4F18
What's New Notification Item 0x0100A2CA87FF01B442AD93F37CD7DD0943EB
Timecard Item 0x0100C30DDA8EDB2E434EA22D793D9EE42058
Resource Group Item 0x0100CA13F2F8D61541B180952DFB25E3E8E4
Users Item 0x0100FBEEE6F0C500489B99CDA6BB16C398F7
List Content Types
------------------------
Item System 0x01
Event Item 0x0102
Reservations Event 0x0102004F51EFDEA49C49668EF9C6744C8CF87D
Schedule and Reservations Event 0x01020072BB2A38F0DB49C3A96CF4FA85529956
Schedule Event 0x0102007DBDC1392EAF4EBBBF99E41D8922B264
Issue Item 0x0103
Announcement Item 0x0104
Link Item 0x0105
Contact Item 0x0106
Message Item 0x0107
Task Item 0x0108
Post Item 0x0110
Comment Item 0x0111
East Asia Contact Item 0x0116
Special Content Types
------------------------
Unknown Document Type Document 0x010104
Press ENTER to continue...