1

In the schema of a component A, there is a "link to component B" field. I want to retrieve the template of that component B in my component A template. I tried the following syntax but it does not work:

<!-- TemplateBeginRepeat name="Component.Fields.slideshare" -->@@RenderComponentPresentation()@@<!-- TemplateEndRepeat -->  

slideshare is the field name in my component A Thanks for your help

6
  • I don't now what you are trying to do... components don't have DWT's. I guess you mean you want to access a component link field withing a DWT in a Component Template? Commented Jul 13, 2016 at 14:29
  • Yes , i expressed myself poorly. I try again: In the schema of a component A, there is a "link to component B" field. I want to retrieve the template of that component B in my component A template
    – user1178
    Commented Jul 13, 2016 at 14:42
  • You can't retrieve template of component B because when linking components there is no template involved. Do you mean you want to render (Component B with Template B) in Template A?
    – Kunal
    Commented Jul 13, 2016 at 15:14
  • Yes that's what i want ! I tried this : @RenderComponentPresentation(Field, "tcm:125-48340-32")@@ but not working unfortunately. the tcm is component B's template
    – user1178
    Commented Jul 13, 2016 at 15:16
  • @@RenderComponentPresentation(Component.Fields.slideshare, "tcm:125-48340-32")@@ should work. Please note that the field names are case sensitive :)
    – Kunal
    Commented Jul 13, 2016 at 15:19

1 Answer 1

1

It only makes sense to call @@RenderComponentPresentation()@@ without arguments when you are iterating over a package item of type ComponentArray. This is what you are doing when you use code such as:

<!-- TemplateBeginRepeat name="Components" -->
@@RenderComponentPresentation()@@
<!-- TemplateEndRepeat -->

after using the default TBB "Extract Components From Page" further up the pipeline. In this case, the components will have been added to the array, and decorated with properties, including the ID of the component template. You can examine these properties by using the technique described here.

You can call RenderComponentPresentation() and pass in the component ID and component template ID as parameters. Depending on what you are trying to do, it might be enough to do this in your DWT TBB.

If you really need to iterate over the components in a Template..Repeat, then you might do better to create a ComponentArray yourself and push it to the package. You can see an example of doing this here. (Note that in the example, the components are already decorated with the component template property, so in your case you'd have to do that.) Obviously the logic for determining which component template to use would depend on your particular use-case.

Your Answer

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