3

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?

1 Answer 1

4

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.

1
  • 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. Commented May 1, 2015 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.