I am trying to render a particular Dreamweaver component template. can anyone help me with the script to display a particular component presentation.

  • How are you going to define "particular component presentation"? Is it TCM URIs of component and template or is it one of the cps that are on the page? – Andrey Marchuk Jul 15 '15 at 14:51
  • one of the cps on the page – Hari Krishna Gaddipati Jul 15 '15 at 15:00
  • What do you know that determines if the CP is the one to render? A unique Schema, Component Template, Order, TCMID? – Chris Morgan Jul 15 '15 at 15:56

You can use the following built in function if you know the Component and Component Template ID

RenderComponentPresentation(string componentUri, string templateUri)

Your DWT syntax would look like

@@RenderComponentPresentation("tcm:x-y-z", "tcm:x-y-z")@@

However, be careful moving between environments as these ID's will change.

| improve this answer | |
  • I tried with tcm numbers but it shows a javascript error "Expected ',' or ')'". even with the quotes to tcm numbers – Hari Krishna Gaddipati Jul 15 '15 at 17:47
  • Add your line of code to your question to help people help you. – Chris Morgan Jul 15 '15 at 17:48
  • This is what I have used.<!-- TemplateBeginRepeat name="Components" --> @@RenderComponentPresentation(string "tcm:7-667494", string "tcm:7-667495-2048")@@ <!-- TemplateEndRepeat --> – Hari Krishna Gaddipati Jul 15 '15 at 17:51
  • First, see my update above. You do not need the "string" text. Secondly, in your code above you are looping all CPs and writing out the same one everytime. Is that the desired output? – Chris Morgan Jul 15 '15 at 17:53
  • It worked. Thank you so much. "@@RenderComponentPresentation("tcm of component","tcm of template")@@"" – Hari Krishna Gaddipati Jul 15 '15 at 18:09

Assuming you want to render a component presentation on a PT.

To render a component presentation selectively, you need a way to identify it. If you want to do it based on the component title, you can do it like below:

 <!-- TemplateBeginRepeat name="Components" -->
   <!-- TemplateBeginIf cond="Component.Title == '[Insert Component Title]'" -->

    <!-- TemplateEndIf -->

<!-- TemplateEndRepeat -->

Read more about the Dreamweaver Templating here

| improve this answer | |
  • This is the error I got, "Optional region does not have a 'cond' parameter specified". My CP name is "LeftMenu CTBB" does the space matter? – Hari Krishna Gaddipati Jul 15 '15 at 16:58
  • try replacing "Cond" with "cond", I guess capital "C" should be the culprit. – Saurabh Gangwar Jul 15 '15 at 17:04
  • No error, but It did not show the content – Hari Krishna Gaddipati Jul 15 '15 at 17:31
  • are you using the above code on "Page Template" ?? – Saurabh Gangwar Jul 15 '15 at 17:38
  • yes. I am using it on the page template – Hari Krishna Gaddipati Jul 15 '15 at 17:48

If you want to render all components using a given template you can use Will Price's Group Components By Template Type TBB found here: https://sdltridionworld.com/community/2011_extensions/generic-2011-tbbs.aspx

This will group all components using the same templates onto an array on your package which you can iterate over using:

            <!-- TemplateBeginIf cond="[Insert Template Name]Components" -->
                <!-- TemplateBeginRepeat name="[Insert Template Name]Components" -->
                <!-- TemplateEndRepeat -->
            <!-- TemplateEndIf -->

Will's code is well commented and includes more details on how it can be used.

| improve this answer | |

Your Answer

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

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