如何在SDL Tridion 2011 SP1中处理Dreamweaver TBB中的嵌套重复区域

Pat*_*tan 7 tridion

我正在使用SDL Tridion 2011 SP1中的DWT TBB.

我有一个嵌入式字段"body",它是多值的.在这个嵌入式字段中,我有一个更简单的文本字段"值",它再次是多值的.

要渲染"value"字段,我必须使用两个重复循环.

但我无法区分两个循环的Indeces.

我写的如下.

<!-- TemplateBeginRepeat name="Component.Fields.body" -->
    <!-- TemplateBeginRepeat name="Component.Fields.body[${TemplateRepeatIndex}].value" -->
    <div>@@RenderComponentField("Fields.body[${TemplateRepeatIndex}].value", TemplateRepeatIndex)@@ </div>
    <!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->
Run Code Online (Sandbox Code Playgroud)

我无法渲染字段.

任何人都可以帮助如何处理DWT TBB中的多个嵌套区域.

谢谢.

Fra*_*len 15

Neil提到Tridion练习页面是一个很好的参考.但该页面显示了如何一般地迭代所有嵌入字段.如果您知道字段名称,事情会变得容易一些.在您的情况下,这就是您的DWT中所需的全部内容:

<!-- TemplateBeginRepeat name="body" -->
    <!-- TemplateBeginRepeat name="Field.value" -->
        <div>@@RenderComponentField(FieldPath+".value", 
                                               TemplateRepeatIndex)@@ </div>
    <!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->
Run Code Online (Sandbox Code Playgroud)

逐行:

  1. 迭代bodyComponent 的字段值
  2. 迭代嵌入模式的value子字段的值body
  3. 在此阶段,FieldPath指的是当前body值,等等body[0],body[1]并且TemplateRepeatIndex是当前的索引value.所以我们可以RenderComponentField用这些知识构建正确的调用.

我有一个包含两个body字段的Component ,每个value字段有两个字段.所以XML是:

<Content xmlns="uuid:8841d68e-7b1b-45cd-a6d6-7e7da5de3ef9">
    <body>
        <value>body1.value1</value>
        <value>body1.value2</value>
    </body>
    <body>
        <value>body2.value1</value>
        <value>body2.value2</value>
    </body>
</Content>
Run Code Online (Sandbox Code Playgroud)

上面这个组件的DWT输出是:

<div><tcdl:ComponentField name="body[0].value"
                          index="0">body1.value1</tcdl:ComponentField></div>
<div><tcdl:ComponentField name="body[0].value" 
                          index="1">body1.value2</tcdl:ComponentField></div>
<div><tcdl:ComponentField name="body[1].value" 
                          index="0">body2.value1</tcdl:ComponentField></div>
<div><tcdl:ComponentField name="body[1].value" 
                          index="1">body2.value2</tcdl:ComponentField></div>
Run Code Online (Sandbox Code Playgroud)

调试这些情况

许多人在编写像这样的结构时遇到了问题.我也不例外,我刚刚发现,我能得到大多数情况下知道的关键变量是工作:Field,FieldPathTemplateRepeatIndex.如果有疑问,只需将此片段嵌入到您的DWT中TemplateBeginRepeat.

(FieldPath=@@FieldPath@@, TemplateRepeatIndex=@@TemplateRepeatIndex@@)
Run Code Online (Sandbox Code Playgroud)


Nei*_*eil 5

请问FieldPath会变量不帮助你在这里?

有关迭代多值嵌入字段的示例,请参见Tridion Practice站点.