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 MarchukCommented Jul 15, 2015 at 14:51
-
one of the cps on the page– Hari Krishna GaddipatiCommented Jul 15, 2015 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 MorganCommented Jul 15, 2015 at 15:56
3 Answers
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.
-
I tried with tcm numbers but it shows a javascript error "Expected ',' or ')'". even with the quotes to tcm numbers Commented Jul 15, 2015 at 17:47
-
Add your line of code to your question to help people help you. Commented Jul 15, 2015 at 17:48
-
This is what I have used.<!-- TemplateBeginRepeat name="Components" --> @@RenderComponentPresentation(string "tcm:7-667494", string "tcm:7-667495-2048")@@ <!-- TemplateEndRepeat --> Commented Jul 15, 2015 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? Commented Jul 15, 2015 at 17:53
-
It worked. Thank you so much. "@@RenderComponentPresentation("tcm of component","tcm of template")@@"" Commented Jul 15, 2015 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]'" -->
@@RenderComponentPresentation()@@
<!-- TemplateEndIf -->
<!-- TemplateEndRepeat -->
Read more about the Dreamweaver Templating here
-
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? Commented Jul 15, 2015 at 16:58
-
try replacing "Cond" with "cond", I guess capital "C" should be the culprit. Commented Jul 15, 2015 at 17:04
-
-
are you using the above code on "Page Template" ?? Commented Jul 15, 2015 at 17:38
-
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" -->
@@RenderComponentPresentation()@@
<!-- TemplateEndRepeat -->
<!-- TemplateEndIf -->
Will's code is well commented and includes more details on how it can be used.