2

My requirement is to store the result of a "rendered" DCP. With DXA since the views will do the rendering portion, my idea was to get the "DCP" from Broker and then get the corresponding partial view in DXA, render it and then store the resultant string. Here are the steps I have -

  1. Get the Component id as a part of the URL request like - /devControls/RenderDCP/tcm_x-y

  2. Get the Entity model using the following call -

    id = id.Replace("_", ":");
    EntityModel model = ContentProvider.GetEntityModel(id, WebRequestContext.Localization);
    
  3. Render the DCP as a string using custom code -

    return Content(RenderPartialToString(model.MvcData.ViewName, model));
    

Everything looks fine theoretically. However, I am failing in the second step itself. When I debug my code, Item tcm_x-y not found. However, I see the item in my Broker DB. Any thoughts on how to proceed with this?

0

1 Answer 1

4

In DXA, the identifier for an Entity based on a DCP has the format <Component Item ID>-<Template Item ID>. For example: for a DCP based on Component tcm:123-456 and Template tcm:123-678-32, the DXA Entity will have ID 456-678.

Note that the DXA identifier doesn't contain a context Publication ID. That is why a Localization instance (which corresponds to a Publication in Tridion) has to be provided too.

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.