I tried to get dynamic component presentation by DXA(Tridion Reference Implementation).What I did is:

  • Create a dynamic component template
  • Create MVC corresponds with the DCT
  • Get dynamic component presentation by Tridion Broker API

But what I got by the API is XML content (which is rendered by DXA default template) and not the HTML content. Is it possible to get HTML content by applying view to the XML?


You should use DD4T's API for this, not the Broker API:

ComponentPresentationFactory.TryGetComponent(componentTcmId, CTTcmId);

Some background: DXA is based on the DD4T framework which sits on top of MVC. This framework provides for publishing the MVC Model from Tridion and control it via MVC Controllers and rendering it via MVC Views. The Model published from Tridion is the serialized Component (Presentation) as XML. So this is what is stored in the Broker. DD4T provides an API to give you the Tridion Component as an object (IComponent), and DXA takes this even further by providing a strongly typed model (see the manual).

For a code example of how to do this, take a look the methods in the BrokerQuery.cs class to see how DXA does this for some dynamic components.

| improve this answer | |
  • 2
    I can do it by getting IComponent instance by DD4T.Factories.ComponentFactory.TryGetComponent, set it to Model class's property, and output field value in View. – Hirokazu Shikata May 1 '15 at 9:17

Your Answer

