How to include/refer a dynamic component template in the page. I had created a dynamic CT and published it, but want to render its presentation in the page. Please suggest.
Thanks in advance,
There are many ways to add dynamic presentation on the page.
Direct Approach - For this your component presentation should be allowed to on page. Check Allow on Page Using Dynamic Assembly. Add the presentation on page same as all others.
Code Approach - You may use API to get your component presentation direct from the broker storage. Here is sample code for the same.
*<%@ Import Namespace="Tridion.ContentDelivery.DynamicContent"%>
<%
ComponentPresentationFactory factory = new ComponentPresentationFactory();
ComponentPresentation ps = factory.getComponentPresentation("CompID","TEMPLATEID");
Response.Write(ps.Content);
%>
JSP example:
<%@ page import="com.tridion.dynamiccontent" %>
<%
ComponentPresentationFactory cpf = new ComponentPresentationFactory("tcm:0-1-1"); // Publication URI
// Component URI and Component Template URI
ComponentPresentation componentPresentation = cpf.getComponentPresentation("CompID", "TEMPLATEID");
out.println(componentPresentation.getContent());
%>
c#
ComponentPresentationFactory cp_factory = new ComponentPresentationFactory(publicationid);
ComponentPresentation cp = cp_factory.GetComponentPresentation(CompID, TEMPLATEID);
if (cp != null)
{
Output = cp.Content;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With