Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 获取本地化站点中的内容类型_Sharepoint_Localization_Types - Fatal编程技术网

Sharepoint 获取本地化站点中的内容类型

Sharepoint 获取本地化站点中的内容类型,sharepoint,localization,types,Sharepoint,Localization,Types,例如,在MOSS2007中,我需要从列表中查找并删除默认内容类型(以便用自定义内容类型替换)。列表可以位于多个站点上,站点可以使用多种语言,并且此内容类型的名称可以不同(例如,英语中的“Wiki页面”,NL中的“Wikipagina”等)。我的想法是使用Id或Id前缀查找内容类型(例如:Wiki页面始终以0x010108开头)。还有更好的主意吗?根据语言的不同,我们可以在代码中获得内容类型的名称吗 private static SPContentType GetWikiPageContentTy

例如,在MOSS2007中,我需要从列表中查找并删除默认内容类型(以便用自定义内容类型替换)。列表可以位于多个站点上,站点可以使用多种语言,并且此内容类型的名称可以不同(例如,英语中的“Wiki页面”,NL中的“Wikipagina”等)。我的想法是使用Id或Id前缀查找内容类型(例如:Wiki页面始终以0x010108开头)。还有更好的主意吗?根据语言的不同,我们可以在代码中获得内容类型的名称吗

private static SPContentType GetWikiPageContentTypeFromList(SPList list)
    {
        string wikiPageStartId = "0x010108";
        foreach (SPContentType contentType in list.ContentTypes)
        {
            string ctId = contentType.Id.ToString();
            if (ctId.StartsWith(wikiPageStartId))
            {
                return contentType;
            }
        }
        return null;
    }
您可以使用类获取内置内容类型id。那么,如果你能使用更好的id,为什么还要使用名字呢

本地化字符串 当然,您也可以使用名称,但您应该使用。检查C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\Resources\core.resx以查看哪些资源名称具有哪些值

string strWikiDocumentTitle = SPUtility.GetLocalizedString("$Resources:WikiDocument", "core", SPContext.Current.Web.Language);
内容类型id和层次结构 说到id,内容类型有,您是对的,像wiki这样的内容类型以及从wiki派生的所有内容类型都将以0x010108开头

不管怎样,你走的路是对的

//Returns best match, that is the content type that is Wiki document. If wiki document content type not in list, will return it's parent content type id.
SPContentTypeId bestMatch = list.ContentTypes.BestMatch(SPBuiltInContentTypeId.WikiDocument);
if (bestMatch.IsChildOf(SPBuiltInContentTypeId.WikiDocument))
{
   return list.ContentTypes[bestMatch];
}
关于列表内容类型的捕获 顺便说一下,返回的内容类型的ID不是0x010108,而是0x010108xxxxxxxxxxxxxxxx。。。。(如果wiki内容类型为CHILD),因为当您将内容类型添加到列表时,它实际上会创建从其父内容类型派生的新内容类型

因此,如果愿意,您可以安全地删除该内容类型。如果要修改该内容类型,则使用返回的内容类型的父级(SPContentType.PARENT属性)修改并应用对继承的所有内容类型的更改…

您可以使用类获取内置内容类型id。那么,如果你能使用更好的id,为什么还要使用名字呢

本地化字符串 当然,您也可以使用名称,但您应该使用。检查C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\Resources\core.resx以查看哪些资源名称具有哪些值

string strWikiDocumentTitle = SPUtility.GetLocalizedString("$Resources:WikiDocument", "core", SPContext.Current.Web.Language);
内容类型id和层次结构 说到id,内容类型有,您是对的,像wiki这样的内容类型以及从wiki派生的所有内容类型都将以0x010108开头

不管怎样,你走的路是对的

//Returns best match, that is the content type that is Wiki document. If wiki document content type not in list, will return it's parent content type id.
SPContentTypeId bestMatch = list.ContentTypes.BestMatch(SPBuiltInContentTypeId.WikiDocument);
if (bestMatch.IsChildOf(SPBuiltInContentTypeId.WikiDocument))
{
   return list.ContentTypes[bestMatch];
}
关于列表内容类型的捕获 顺便说一下,返回的内容类型的ID不是0x010108,而是0x010108xxxxxxxxxxxxxxxx。。。。(如果wiki内容类型为CHILD),因为当您将内容类型添加到列表时,它实际上会创建从其父内容类型派生的新内容类型

因此,如果愿意,您可以安全地删除该内容类型。如果要修改该内容类型,请使用返回的内容类型的父级(SPContentType.PARENT属性)修改并将更改应用于继承的所有内容类型