6

I have a multi-valued embedded schema containing a text field and a multi-valued component link. I am currently using the common get linked components TBB to add the components to the package, but due to the schema being multi-valued, they are added with a prefix such as 'comp0', 'comp1', etc.

The outter loop is simple, however when I need to access the multi-valued component links I have no way of accessing the unique name on the package. The simplest solution that I can think of is to use the TemplateRepeatIndex inside of the conditional, such as:

<!-- TemplateBeginRepeat name="comp{$TemplateRepeatIndex}.fieldName" -->

However this is not working. Is this even possible? If so, what is the proper syntax?

Thanks

1

3 Answers 3

6

This is not possible via DWT. The 'name' value of TemplateBeginRepeat cannot be evaluated. You can write another TBB that loops through the package finding your comp1, comp2 and etc and rendering each component.

You can also use @@RenderComponentPresentation(compID, templateID)@@ inside your top-level CT and avoid relying on GetLinkedComponents.

Finally you can use the Dreamweaver Get Extension (https://sdltridionworld.com/community/extension_overview/dreamweaver_get_extension.aspx) to render nested components or wrote your own Dreamweaver Function Source.

1
5

You can also use the Nuno's Get Extension that is available here

That approach is very interesting and very useful, you don't need to create a C# TBB, but you will need to register the Get extension in the GAC.

3

I'd also suggest using (what i call) the 'inner component presentation' method where you render the sub components by using the RenderComponentPresentation() method from your 'outer' component template.

It's not easy to describe, frank has done a great job of explaining this method here:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.