我知道开箱即用,我们可以使用以下内容循环或迭代DWT 模板构建块 (TBB) 中的数组。
<!-- TemplateBeginRepeat name="array_name" -->
<!-- template logic -->
<!-- TemplateEndRepeat -->
总之,我们可以使用:
Component
在迭代组件或组件表示时引用当前组件ComponentTemplate
在迭代组件表示时引用当前组件模板(这将在页面级别)Field
在迭代字段和多值字段时引用当前字段。FieldPath
获取迭代项的完整路径。TemplateRepeatIndex
在嵌套循环中使用时很有用,如The Tridion Practice Cookbook中所示。*TemplateRepeatIndex
,从零开始的循环计数。
我们可以在组件数组循环内的给定组件上进行嵌套循环Fields
,以及在迭代多值字段时有条件地检查特定字段名称。
我已经通过嵌套 DWT 的语法看到了双重查找(例如@@Image_${TemplateRepeatIndex}@@
,如 Yet Another Tridion Blog 中所述)。
问题)
可以肯定的是,这些是复合模板中的项目或数组/集合Package
,对吧(默认情况下或由我们的代码放置)?
我们可以“迭代”一个包中的单独项目吗?
例如,如果我们在 中有单独的组件Package
,我们可以用类似的东西“迭代”它们@@Component${TemplateRepeatIndex}@@
吗?
- 组件1
- 组件2
- 组件3
我看到我可以在循环中引用这样的项目,但我所看到的一切都表明以下是不可能的:
<!-- TemplateBeginRepeat name="@@Component${TemplateRepeatIndex}@@" -->
<!-- do something with @@Component${TemplateRepeatIndex}@@ -->
<!-- TemplateEndRepeat -->