如何在 SDL Tridion 2011 SP1 中处理 Dreamweaver TBB 中的嵌套重复区域 [英] How to handle nested repeating regions in Dreamweaver TBBs in SDL Tridion 2011 SP1

查看:30
本文介绍了如何在 SDL Tridion 2011 SP1 中处理 Dreamweaver TBB 中的嵌套重复区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 SDL Tridion 2011 SP1 中处理 DWT TBB.

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

要呈现值"字段,我必须使用两个重复循环.

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

我写的如下.

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

我无法渲染字段.

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

谢谢.

解决方案

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

<!-- TemplateBeginRepeat name="Field.value" --><div>@@RenderComponentField(FieldPath+".value",TemplateRepeatIndex)@@ </div><!-- TemplateEndRepeat --><!-- TemplateEndRepeat -->

逐行:

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

示例

我有一个带有两个 body 字段的组件,每个字段都有两个 value 字段.所以 XML 是:

<身体><value>body1.value1</value><value>body1.value2</value><身体><value>body2.value1</value><value>body2.value2</value></内容>

上述 DWT 在这个组件上的输出是:

调试这些情况

许多人在编写此类结构时遇到问题.我也不例外,我刚刚发现,通过知道关键变量是:FieldFieldPathTemplateRepeatIndex,我可以使大多数案例工作.如有疑问,只需将此片段嵌入到每个 TemplateBeginRepeat 内的 DWT 中即可.

(FieldPath=@@FieldPath@@, TemplateRepeatIndex=@@TemplateRepeatIndex@@)

I am working on DWT TBB in SDL Tridion 2011 SP1.

I have a embedded field "body" which is multivalued. In this embedded field I have one more simple Text field "value", which is again multivalued.

To render the "value" field I have to use two repeating loops.

But I am unable to differentiate the Indeces of the both loops.

I have written as follows.

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

I am unable to render the fields.

Can any one help how to handle multiple nested regions in DWT TBB.

Thank you.

解决方案

The Tridion practice page that Neil referred to is a good reference. But that page shows how to generically iterate over all embedded fields. In cases where you know the field name, things get a bit easier. In you case, this is all that is needed in your DWT:

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

Line by line:

  1. Iterate over the values of the body field of your Component
  2. Iterate over the values of the value subfield of your body embeddable schema
  3. At this stage the FieldPath refers to the current body value, so body[0], body[1], etc. and TemplateRepeatIndex is the index of the current value. So we can construct the correct RenderComponentField call with this knowledge.

Example

I have a Component with two body fields, each with two value fields. So the XML is:

<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>

The output from the above DWT on this Component is:

<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>

Debugging these situations

Many people have problems writing constructs like these. I am no exception, I have just found that I can get most cases working by knowing that the crucial variables are: Field, FieldPath and TemplateRepeatIndex. When in doubt, simply embed this fragment into your DWT inside every TemplateBeginRepeat.

(FieldPath=@@FieldPath@@, TemplateRepeatIndex=@@TemplateRepeatIndex@@)

这篇关于如何在 SDL Tridion 2011 SP1 中处理 Dreamweaver TBB 中的嵌套重复区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆