2

I'm trying to write the Dreamweaver TBB and I am stuck at one point where I need to get the field value at a different template level.

Below is my XML where I need to get the inputType field present at formField level to the input Templating level.

<formField>
    <divClassName>fieldClassName</divClassName>
    <label>Please enter your Name</label>
    <labelId>labelNameId</labelId>
    <inputType>text</inputType>
    <input>
        <inputName>sam</inputName>
        <inputId>ssss</inputId>
        <inputSize>40</inputSize>
        <inputLabel>xxx</inputLabel>
        <inputValue>zzz</inputValue>
    </input>
    <input>
        <inputName>gf</inputName>
        <inputId>g</inputId>
        <inputSize>fdg</inputSize>
        <inputLabel>sg</inputLabel>
        <inputValue>gsdfg</inputValue>
    </input>
    <param1>ssss</param1>
    <param2>ssss</param2>
</formField>

To get the value in the same level we can use

<!-- TemplateBeginRepeat name="Component.Fields.formField" -->
    @@inputType@@
<!-- TemplateEndRepeat -->

But my requirement is to get the inputValue at input templating level

<!-- TemplateBeginRepeat name="input" -->
    @@inputType@@
<!-- TemplateEndRepeat -->

This code fails to return as there is no inputType present at input templating level. So i tried to use:

<!-- TemplateBeginRepeat name="input" -->
    @@RenderComponentField("formField[0].inputType",0)@@
<!-- TemplateEndRepeat -->

Here there are two issues when i use RenderComponentField the output looks like:

<tcdl:ComponentField name="formField[0].inputType" index="0">
    text
</tcdl:ComponentField>

its returning the value along with tcdl tags which I don't require.

Secondly, instead of the index directly giving 0 , I need to use TemplateRepeatIndex, but its giving an error if i use @@RenderComponentField("formField[TemplateRepeatIndex].inputType",0)@@

So how can we achieve this if we want to get the field value at a different templating level.

Chris Summers
  • 10,153
  • 1
  • 21
  • 46
Sam
  • 123
  • 2

3 Answers3

2

As you have discovered, it is not possible to access the "outer" TemplateRepeatIndex from the "inner" loop with the standard DWT functions.

There are a few ways to solve this. The simplest is probably to write custom Dreamweaver callable functions that use the context variables to store and retrieve values.

This approach is described well, with accompanying source code, at Get and Set Variables in DWTs | SDL Tridion Developer

David Forster
  • 1,390
  • 9
  • 16
  • Thanks David . I have used DGX extension and i can use its functionalities but when i try to build a dll for Get and Set Variables in DWTs in my project and after adding that dll in the GAC . the get and set variable functions are not getting recognized . can you provide me the dll for that. – Sam Feb 08 '13 at 08:53
1

you have to use $ sign like below with TemplateRepeatIndex

@@RenderComponentField("formField[${TemplateRepeatIndex}].inputType",0)@@

Let me know if not work

Priyank Gupta
  • 942
  • 1
  • 7
  • 26
1

Your question is a little confusing, but it seems like you have 2 issues

  1. You have an extra <tcdl:ComponentField/> tag which you don't want
  2. You get an error when you use TemplateRepeatIndex

If that is not correct, please consider modifying your question.

For issue number #1- can I assume you are seeing the <tcdl:ComponentField/> in Template Builder? Or are you seeing this in the final published page? This tag is added to the output by the @@RenderComponentField@@ function to allow you to add SiteEdit of TridionUI markup to your output. If should not end up in your published pages if you apply the 'Default Finish Actions' TBB at the end of your template. The default templates contain code to clean up this tags after any SiteEdit/UI markup is applied.

For your second issue, take a look at these post 'How to handle nested repeating regions in Dreamweaver TBBs in SDL Tridion 2011 SP1' and 'http://www.tridiondeveloper.com/get-and-set-variables-in-dwts'.

Nested/embeded fields can be confusing using the default Tridion syntax for Dreamweaver, so you might consider using the great GetExtension from Nuno Linhares. This will make your life much easier

Community
  • 1
  • 1
Chris Summers
  • 10,153
  • 1
  • 21
  • 46
  • Thanks Chris for the response , i already had a look at the DGX extension . Here they are using @@Get("Fields.Link[${TemplateRepeatIndex}].InternalLink.Fields.ThumbnailImage")@@ . But in my case i need to use two template repeat index where one belongs to parent and the other to the child.For Example column[${TemplateRepeatIndex}].formField[${TemplateRepeatIndex}].inputType . here the template repeat in actual is different for the parent(column) and child (formField) but the code takes the child's template repeat index in both the cases . so it fails . – Sam Feb 06 '13 at 12:54
  • 1
    Then (as David suggests), I suggest you look at variables: http://www.tridiondeveloper.com/get-and-set-variables-in-dwts – Chris Summers Feb 06 '13 at 14:17