How to include Dynamic component presentation in the tridion page?

最后都变了- 提交于 2019-12-22 08:19:10

问题


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,


回答1:


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;
}



回答2:


There is multiple ways to show a Dynamic Presentation on a page:

  • the most simple one is marking your Dynamic CT as "Allow on Page Using Dynamic Assembly", then you will be able to embed it on your page as a Non-Dynamic CT

  • For more advanced alternatives, you can check the Live Content Documentation: Implementing Content Delivery > Developing Web Pages


来源:https://stackoverflow.com/questions/12799509/how-to-include-dynamic-component-presentation-in-the-tridion-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!