4

I'm using DD4T and have some XML being generated which I can now query from the OData service. Unfortunately the DD4T content comes back serialised into the content property of the response.

This links back to the question I asked on connecting the two aspects of DD4T - the CM side sticks out XML into the broker, which is fine... but I want some way of creating a loosely coupled platform independent way of retrieving the right content on a URI request to a REST service, meaning MV* patterns can be employed without any dependency on a language.

example:

URL requested - http://test.site/Home/Index

Request routed to a service which then takes over the DD4T function and can sort out the response to the client, with complete component link resolution, into some arbritary data format (JSON in my case)

Rob Stevenson-Leggett kindly provided the link to the OData service provider from DD4T->TCDS - I'm presuming DD4T on the web application side hasn't been RESTified up yet by anyone?

  • As far as I know, the link Rob sent you is the only attempt to RESTify dd4t. Have you tried that out? The fact that the content comes back as a string in the content property is to be expected. DD4T is all about serializing in templates, and deserializing on the front end, so why should the OData approach be any different? – Quirijn May 22 '13 at 19:12
  • I understand that, but I was really enquiring why the de-serialisation couldn't be done first. For example if I was creating an iPad app, and a Web Site, it's a repeated (and wasted) effort to create what may well be the same de-serialisation function on both platforms, given that I want JSON as a constant output format. Sorry for the novice questioning. – mpaton May 22 '13 at 19:53
5

This is how I implement this type of functionality, feel free to disagree with me:

  1. Request comes in for page /somepath/index
  2. Query to OData to get /Pages()?$filter=Url eq '%2Fsomepath%2Findex'
  3. Potentially use a $expand(PageContent) on that URL so that it brings the presentation content as well
  4. Load the PageContent, it's been escaped because Tridion cannot guarantee the output of templates are well-formed, so parse it in XML, probably with a strong domain model
  5. From there on, build my page.

EDIT

Tridion Component links that are part of the content are resolved, as long as the output from the Tridion publisher is converted to a <tcdl:Link> object. Something called "REL" - Render Engine Language - will convert those <tcdl:Link> to the actual result.

EDIT 2

That same query for the pages could also be written like this:

var page = (from p in contentdeliveryservice.Pages
           where p.Url == '/somepath/index'
           select p).First();
  • Thanks - how is the URI navigation scheme defined? i.e where is /somepath/index defined? Is that congruous to structure group hierarchy or do you maintain a separate mapping on your application? – mpaton May 22 '13 at 19:50
  • 1
    Open /Pages on your OData endservice point - or look at /$metadata for the whole relationship. I would also recommend looking at LINQ with OData - editing my answer for an example with LINQ – Nuno Linhares May 22 '13 at 19:54

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.