10

I have a use case where I need to determine if a particular template on the Content Delivery side has the output format of REL.

The reason is because I'm trying to determine whether to use the ComponentPresentationFactory or the ComponentPresentationAssember for my evil deeds.

On the CM we set the Output Format on a Component Template as follows:

enter image description here

On the CD side, it is not obvious how to leverage this parameter.

The CD API's ComponentPresentationFactory has a method GetComponentPresentationWithOutputFormat, e.g.:

var cp = cpFactory.GetComponentPresentationWithOutputFormat(tcmUri.ItemId, "REL");

This tells me that the information about a CT's output format is stored on the CD side.

(As a side thought/question, I may have multiple CTs for a given component that are REL. So what which one would the above method return, the highest priority one, or the first one it finds?)

Another supporting argument that the OutputFormat exists on the CD side is that the Tridion.ContentDelivery.Meta.ITemplateMeta interface has a OutputFormat property as per the documentation. But I can't, for the life of me, figure out how to get an instance of ITemplateMeta based on a template ID.

I am trying to avoid having to publish any XML or JSON files from the CM with a listing of REL templates because that just seems hacky.

Can anyone please shed some light on how to get the OutputFormat on the CD side?

10

Something like this should work:

using (var ctTypeCriteria = new ItemTypeCriteria(32))
{
      using (var idCriteria = new ItemReferenceCriteria(3148))
      {
           var ctAndIdCriteria = new AndCriteria(ctTypeCriteria, idCriteria);
           var outputFormat = ((ITemplateMeta)new Tridion.ContentDelivery.DynamicContent.Query.Query(andCrit).ExecuteEntityQuery().First()).OutputFormat;
      }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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