简体   繁体   English

如何在SDL Tridion 2011 SP1中获取模板的组件

[英]How to get components of a template in SDL Tridion 2011 SP1

I am newbie in Tridion. 我是Tridion的新手。 I am looking for some sample code for a TBB to get all components for a component template. 我正在寻找TBB的一些示例代码来获取组件模板的所有组件。 I have seen examples of how to get components of a page or from a folder but not for this. 我已经看到了如何获取页面组件或文件夹但不是这样的示例。

I could get the count by using object.GetListUsingItems(filter).SelectNodes(*).Count in my template, but I need a way to iterate all components and get Title or other attributes of Components. 我可以通过使用object.GetListUsingItems(filter).SelectNodes(*).Count得到计数object.GetListUsingItems(filter).SelectNodes(*).Count在我的模板中计算,但我需要一种方法来迭代所有组件并获得组件的Title或其他属性。

Please advise. 请指教。

You cannot get all components for a template in one go, you need to look first at which Schemas are associated with this component template, then get all components for each schema. 您无法一次性获取模板的所有组件,您需要首先查看与此组件模板关联的模式,然后获取每个模式的所有组件。 Be aware of Blueprint contexts when doing this. 这样做时要注意蓝图上下文。

I'm slightly confused as to what you're trying to achieve with this, if you want to do this as part of a publishing action you would very quickly end up with massive publish transactions with many components in it. 我对你想要实现的目标感到有些困惑,如果你想在发布行动中做到这一点,你很快就会发现包含许多组件的大量发布事务。

If you want more attributes than exposed in Lists, then use GetUsingItems instead - but be aware that this is a considerably slower operation with a lot more database interactions than getting a list. 如果您想要更多属性而不是列表中公开的属性,那么请使用GetUsingItems - 但请注意,这是一个相当慢的操作,与获取列表相比,数据库交互要多得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM