简体   繁体   English

在“嵌入式​​”字段中循环组件链接

[英]Looping component links in an Embedded field

We have a "component A" , which has a multivalue field of type 'embedded field'. 我们有一个“组件A”,它具有类型为“嵌入式字段”的多值字段。 The embedded field in turn has a multivalue field of type ' Component Link '. 嵌入字段又具有类型为“ 组件链接 ”的多值字段。

This looks like: Component A -> Embedded Shcema Fields -> Component Links 看起来像: 组件A->嵌入式Shcema字段->组件链接

How to iterate and access the fields of 'Component Links 'in dreamweaver? 如何在Dreamweaver中迭代和访问“组件链接 ”的字段? Also the component field supports three different schemas and We want to check on these schema names in dreamweaver. 组件字段也支持三种不同的模式,我们想在Dreamweaver中检查这些模式名称。

I found this post useful. 我发现这篇文章很有用。 But more details would be indeed great. 但是更多细节确实很棒。

Have a look at these questions: 看一下这些问题:

And this page from the Tridion practice cookbook: 而Tridion练习手册中的以下页面:

They cover the most common problems you may have with accessing fields in a DWT. 它们涵盖了您在DWT中访问字段时可能遇到的最常见问题。

If these don't answer your question, update your question with: 如果这些不能回答您的问题, 使用以下方法更新您的问题

  1. the relevant XML fragment of your Component 组件的相关XML 片段
  2. the DWT fragment showing what you already tried DWT 片段显示您已经尝试过的内容

You can easily iterate through component link of multi value embedded field but there is no direct way to get component link values, you have to use either dwt extension, or .net tbb. 您可以轻松地通过多值嵌入字段的组件链接进行迭代,但是没有直接方法来获取组件链接值,您必须使用dwt扩展名或.net tbb。 There are some available on sdltridionworld.com. sdltridionworld.com上有一些可用的。

I did this earlier with nested template. 我之前使用嵌套模板来完成此操作。 You may also try nested/sub template from your main dwt tbb based on schema of component link field component in the loop. 您还可以根据循环中组件链接字段组件的模式,尝试从主dwt tbb中嵌套/子模板。

Also I would suggest to use razor templates. 我也建议使用剃刀模板。

You can iterate through the multi-value field paragraph in the embedded schema field paragraphs as follows: 您可以按以下步骤遍历嵌入式模式字段段落中的多值字段段落:

<!-- TemplateBeginRepeat name="Component.Fields.paragraphs" -->

    <h2>@@Field.header@@ (@@TemplateRepeatIndex@@)</h2>
    <!-- TemplateBeginRepeat name="Field.paragraph" -->
        <p>@@Field@@</p>
    <!-- TemplateEndRepeat -->

<!-- TemplateEndRepeat -->

As Vikas previously mentioned, repeating over the multivalued component link field of a multivalued embedded schema field is relatively simple. 正如Vikas前面提到的,在多值嵌入式架构字段的多值组件链接字段上重复相对简单。 Your DWT code should follow this form: 您的DWT代码应遵循以下格式:

<!-- TemplateBeginRepeat name="XML Name of Embedded Schema Fields" -->
    <!-- TemplateBeginRepeat name="XML Name of multivalued Component Link field" -->
        @@Field@@  - Should write out the TCM ID of your linked component
    <!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->

You can not, however, access the fields or schema details of these components with "out of the box" Dreamweaver Templates. 但是,您无法使用“开箱即用”的Dreamweaver模板访问这些组件的字段或架构详细信息。

You can: 您可以:

  1. install the Dreamweaver Get eXtension on your Content Manager server, which will allow you to retrieve fields of linked components (amongst other things) using the @@Get(...)@@ syntax 在您的Content Manager服务器上安装Dreamweaver Get eXtension ,这将允许您使用@@Get(...)@@语法检索链接组件的字段(以及其他内容) @@Get(...)@@
  2. Use the "Get Linked Components" .Net TBB from the Generic SDL Tridion 2011 Template Building Blocks before your Dreamweaver Template, which will place the linked components into the templating package so that you can iterate over them directly 在Dreamweaver模板之前,使用通用SDL Tridion 2011模板构建块中的“获取链接的组件” .Net TBB,它将链接的组件放入模板包中,以便您可以直接对其进行迭代
  3. Write your own .Net TBB to handle your specific business logic related to these links and output html (not recommended) or a named package item, items or array of items that you can handle from your DWT. 编写您自己的.Net TBB来处理与这些链接有关的特定业务逻辑,并输出html(不推荐)或可从DWT处理的已命名包物料,物料或物料阵列。
  4. Call another (nested) component template from your DWT with @@RenderComponentPresentation(Field, "tcm:x-xx-32")@@ 使用@@RenderComponentPresentation(Field, "tcm:x-xx-32")@@从DWT调用另一个(嵌套的)组件模板。
  5. Any combination of the above 以上任意组合

Please try using below code: 请尝试使用以下代码:

          <!-- TemplateBeginRepeat name="paragraphs" -->
               <!-- TemplateBeginRepeat name="Internal_Link" -->
                 <!-- TemplateBeginIf cond = "Internal_Link != ''" -->
                    <p> @@Component.ID@@ </p>
                 <!-- TemplateEndIf -->
               <!-- TemplateEndRepeat -->
         <!-- TemplateEndRepeat -->

To check for zeroth component you can use below code: 要检查零分量,可以使用以下代码:

          <!-- TemplateBeginRepeat name="paragraphs0.Internal_Link" -->

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

相关问题 在.NET Assembly TBB中遍历多值字段和嵌入式架构字段 - Looping through a multivalued field and embedded schema field in .NET Assembly TBB 组件链接在 64 位模式下不工作 - Component Links not working in 64 bit mode SDL Tridion架构字段“链接列表”选项 - SDL Tridion Schema Field “List of Links” Options 组件模板和页面模板需要TBBS,以通过组件链接实现组件的SiteEdit - TBBS required for Component Template and Page Template to implement SiteEdit for Component with component links 发布组件时更新组件字段 - Updating component field while publishing the component 在具有组件链接的组件上使用SiteEdit / TridionUI 2012启用内联编辑 - Enabling inline editing with SiteEdit/TridionUI 2012 on a component that has Component Links Tridion:循环链接组件时的组件模板问题 - Tridion: Component Template issue when looping over linked components 创建一个从另一个组件复制字段值的组件 - Creating a component that copies field values from another component 递归函数以遍历模式中的每个嵌入式模式字段以到达叶数据字段 - Recursive function to going through each embedded schema field in a schema to reach a leaf data field 如何在Dreamweaver模板构建块中检查嵌入式架构中的字段是否为空 - How to check if the field in embedded schema is empty in Dreamweaver Template Building Block
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM