Monday 25 May 2009 1:49:31 pm
The ggxmlview on projects.ez.no extension already provides a basis for creating json-formatting of nodes via the templating system. It can be taken as-is or as an example.
You can of course use an {if} inside your pagelayout to switch to the desired output format, but I would rather
a - set up a wildcard url-alias rule, so that eg. www.mysite.com/json/23 redirects to www.mysite.com/layout/set/json/content/view/json/23 b - use a different siteaccess, dedicated to json, where the default pagelayout and node_view_full templates are the json ones. This means you do not need to set up url-alias rules and will benefit from virtual urls
The advantage is that
- you keep your standard templates clean of json stuff - you can set up a proper content-type header for json content The thing you have to consider is the view-cache: by default only the full view of nodes benefits of it, so if you use a different view mode you will need to change your settings accordingly.
Principal Consultant International Business
Member of the Community Project Board
|