gpt4 book ai didi

tridion - 使用 Tridion Core Service 的 GetListUsingItems 返回的项目比 TOM 更多

转载 作者:行者123 更新时间:2023-12-02 04:08:57 25 4
gpt4 key购买 nike

我想使用 Tridion 核心服务的 GetListUsingItems 方法获取蓝图项目的所有子项目。与使用 TOM 中的旧方法相比,我使用核心服务得到了不同的结果(更多)。看来我还通过组件链接返回引用我的源组件的其他组件。我是否缺少核心服务中的过滤器选项?

Tridion 5.3:

Function GetLocalizedItemNodes(itemUri)
Dim tridionItem : set tridionItem = tdse.GetObject(itemUri,1)
Dim rowFilter : set rowFilter = tdse.CreateListRowFilter()
call rowFilter.SetCondition("ItemType", GetItemType(itemUri))
call rowFilter.SetCondition("InclLocalCopies", true)
Dim usingItemsXml : usingItemsXml = tridionItem.Info.GetListUsingItems(1919, rowFilter)

Dim domDoc : set domDoc = GetNewDOMDocument()
domDoc.LoadXml(usingItemsXml)
Dim nodeList : set nodeList = domDoc.SelectNodes("/tcm:ListUsingItems/tcm:Item[@CommentToken='LocalCopy']")

set tridionItem = nothing
set domDoc = nothing
set GetLocalizedItemNodes = nodeList
End Function

Tridion 2011 SP1 核心服务:

   private XElement GetLocalizedItems(string itemUri)
{
XElement usingXML = null;
try
{
CoreServiceClient client = new CoreServiceClient();
client.ClientCredentials.Windows.ClientCredential.UserName = ConfigurationManager.AppSettings["impersonationUser"].ToString(); // "administrator";
client.ClientCredentials.Windows.ClientCredential.Password = ConfigurationManager.AppSettings["impersonationPassword"].ToString();
client.ClientCredentials.Windows.ClientCredential.Domain = ConfigurationManager.AppSettings["impersonationDomain"].ToString();

// original code from http://www.tridiondeveloper.com/getting-used-items-using-the-core-service
// Create a filter
UsingItemsFilterData usingItemsFilterData = new UsingItemsFilterData
{
BaseColumns = ListBaseColumns.IdAndTitle, // to specify the detail in the XML
IncludeLocalCopies = true,
ItemTypes = new[] { ItemType.Component }
};
// Get the XML by calling .GetListXml on the client (assumes you have a 'client' object already)
usingXML = client.GetListXml(itemUri, usingItemsFilterData);

}
catch (Exception ex)
{
throw;
}
return usingXML;
}

最佳答案

您应该使用BluePrintChainFilterData:

BluePrintChainFilterData filter = new BluePrintChainFilterData();
filter.Direction = BluePrintChainDirection.Down;
var result = ClientAdmin.GetListXml("tcm:3-1905", filter);

请注意,您可以指定Direction属性。但是,此过滤器不会向您显示共享项目。另外,尽量避免使用UsingItemsFilterData,因为它对数据库的占用很大

如果您还想包含共享项目,则可以使用BluePrintFilterData:

BluePrintFilterData filter = new BluePrintFilterData();
filter.ForItem = new LinkToRepositoryLocalObjectData{ IdRef = "tcm:3-1905"};
var listXml = ClientAdmin.GetSystemWideListXml(filter);
var list = ClientAdmin.GetSystemWideList(filter);

您可以在此处指定 ForItem 属性来设置您的项目。它会返回如下内容:

<tcm:ListBluePrintNodes Managed="1" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" xmlns:xlink="http://www.w3.org/1999/xlink">
<tcm:BluePrintNode ID="tcm:0-3-1" Title="Test" Icon="T1L0P0">
<tcm:Item ID="tcm:3-1905" Title="Test multimedia component" ItemType="16" IsShared="False" IsLocalized="False" IsPublished="False" LockType="0" LockUser="tcm:0-0-0" Icon="T16L0P0Mgif"></tcm:Item>
</tcm:BluePrintNode>
<tcm:BluePrintNode ID="tcm:0-172-1" Title="test_child" Icon="T1L0P0">
<tcm:Parents>
<tcm:Parent xlink:href="tcm:0-3-1" xlink:title="Test" Priority="1"></tcm:Parent>
</tcm:Parents>
<tcm:Item ID="tcm:172-1905" Title="Test multimedia component" ItemType="16" IsShared="True" IsLocalized="False" IsPublished="False" LockType="0" LockUser="tcm:0-0-0" Icon="T16L0P0Mgif"></tcm:Item>
</tcm:BluePrintNode>
</tcm:ListBluePrintNodes>

系统范围列表的好处是您可以使用 GetSystemWideList 方法,该方法将返回 BluePrintNodeData 对象数组,而不是 XML

关于tridion - 使用 Tridion Core Service 的 GetListUsingItems 返回的项目比 TOM 更多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9515647/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com