How to enable dynamic view of components on a tridion page?

How to enable / reference the dynamic component template on the page. I created a dynamic CT scan and published it, but I want to display its presentation on the page. Please suggest.

Thanks in advance,

+4
source share
2 answers

There are many ways to add a dynamic presentation to a page.

Direct approach. For this, the presentation of your component must be allowed on the page. Select the Allow per page using dynamic assembly check box. Add a presentation to the page just like everyone else.

Code approach. You can use the API to get the component view directly from the broker's repository. Here is a sample code for it.

*<%@ 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()); %> 

WITH#

 ComponentPresentationFactory cp_factory = new ComponentPresentationFactory(publicationid); ComponentPresentation cp = cp_factory.GetComponentPresentation(CompID, TEMPLATEID); if (cp != null) { Output = cp.Content; } 
+12
source

There are several ways to display a Dynamic View on a page:

  • the simplest of them designates your Dynamic CT as "Allow on Page Using Dynamic Assembly" , then you can embed it on your page as a non-dynamic CT

enter image description here

+6
source

Source: https://habr.com/ru/post/1438641/


All Articles