3

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 but it does not work:

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

(slideshare is the field name in my component A)

and

<!-- TemplateBeginRepeat name="Component.Fields.slideshare" -->
   @RenderComponentPresentation(Field, "tcm:125-48340-32")@@
<!-- TemplateEndRepeat -->

(where the tcm is my component B's template)

Thanks for your help

migrated from stackoverflow.com Jul 19 '16 at 3:08

This question came from our site for professional and enthusiast programmers.

  • Hi Arnaud, welcome to Tridion Stack Exchange. To help us answer your question, could you clarify what type of field is "slideshare" and is it multivalue? I think you may need to investigate putting ComponentPresentations and Template IDs in the Package using a C# TBB alongside your DWT. Have a look at the templating extensions on SDL Tridion World: sdltridionworld.com/community/extension_overview/… and sdltridionworld.com/community/extension_overview/… – Rob Stevenson-Leggett Jul 19 '16 at 13:30
  • Also, I would avoid hard coding TCM IDs in templates whereever possible as this could cause you problems later. – Rob Stevenson-Leggett Jul 19 '16 at 13:30
  • Hello,Thank you for your help. slideshare is a link to component field. It is not multivalue. I'm going to check the files you recommended – user1178 Jul 20 '16 at 8:55
2

Here is my suggestion. You can via C# code extract your linked component B. Then you can check all templates it can be rendered with and push tcm of selected one into package. Then you can render all your components with that template like this:

<!-- TemplateBeginRepeat name="Component.Fields.slideshare" -->
   @RenderComponentPresentation(Field, ${desiredTemplateID})@@
<!-- TemplateEndRepeat -->

Also, you can optimize this code by creating some configuration component with templates keys and WebDAV paths and read that component and push into package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy