2

I know it is possible to send ComponentArray but here i need to pass a dummy array to create a collection loop in DWT. Am unable to pass dummy componentArray as it throws item not found error. Any hints is highly appreciated.

2 Answers 2

3

No, unfortunately what you're trying to do is not possible in DWT/TEL. As you've found, custom & dummy arrays don't work in the package.

I'd suggest that you create the desired output markup in a C# TBB (either in the one where you're creating your array of data, or by serialising the data and then de-serialising it in a subsequent TBB) and pushing that HTML snippet as a string into the package. Then just use a simple @@MyCustomStringName@@ to pull that into the resulting output in your DWT.

As Alvin mentions in the comments, there is some possibility to create and loop over simple string arrays. I'm not sure if this is fully supported (i.e. "upgrade-proof").

3
  • 1
    Per Andrey's last post, you can iterate over string arrays as of SDL Tridion 2013 SP1. You do need to serialize the array of strings. Commented Feb 8, 2016 at 10:28
  • Nice. Thanks for the reminder. Useful for things like tag or category strings perhaps, and maybe you could use it to render other ComponentPresentations if you passed strings of Component IDs? Would be good to know if it's actually supported or not, as Andrey states it is more of a side effect of some other functionality that was added. Commented Feb 8, 2016 at 10:38
  • 1
    It worked fine using Andrey's post, Commented Feb 8, 2016 at 18:06
2

You can create a "Dummy Component Array" that will be used only as counter for the values that are previously added to the package with number suffix. This way you use Dummy Component Array just for DWT Repeater and it's TemplateRepeatIndex to create an exact name of package you want to retrieve.

<!-- TemplateBeginRepeat name="MyDummyArray" -->
  @@Var_${TemplateRepeatIndex}@@
<!-- TemplateEndRepeat -->

For the "Dummy Component Array" you can use any dummy TCMURI, they can all be tcm:0-0-0.

This way was already explained\ in post what-can-we-loop-over-in-dwt-layout-template-building-blocks

2
  • Personally I'm not keen on that method. It relies on pushing multiple items to the package, the array and the other items count must be aligned and it relies on a double-lookup of the TEL syntax. It does work, but it's just too untidy for my taste. Commented Feb 8, 2016 at 18:14
  • I agree with you David, your and Andrey's solution is much more cleaner and better, but for completeness of the post I added this solution also. Commented Feb 9, 2016 at 8:58

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.