如何在页面中包含/引用动态组件模板。我创建了一个动态 CT 并发布了它,但想在页面中呈现其演示文稿。
请建议。
提前致谢,
有很多方法可以在页面上添加动态呈现。
直接方法 - 为此,您的组件演示应允许在页面上进行。查看允许在页面上使用动态装配。与所有其他页面相同,在页面上添加演示文稿。
代码方法 - 您可以使用 API 直接从代理存储获取组件演示。
这是相同的示例代码。
*<%@ 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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)