如何在 tridion 页面中包含动态组件展示? [英] How to include Dynamic component presentation in the tridion page?

查看:18
本文介绍了如何在 tridion 页面中包含动态组件展示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在页面中包含/引用动态组件模板.我创建了一个动态 CT 并发布了它,但想在页面中呈现它的演示文稿.请提出建议.

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.

提前致谢,

推荐答案

有很多方法可以在页面上添加动态演示.

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.

代码方法 - 您可以使用 API 直接从代理存储获取组件演示.这是相同的示例代码.

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

这篇关于如何在 tridion 页面中包含动态组件展示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆