Share » Forums » Setup & design » JSON feed of nodes

JSON feed of nodes

JSON feed of nodes

Monday 25 May 2009 11:42:29 am - 2 replies

Modified on Monday 25 May 2009 11:44:25 am by Luigi Spagnolo

Author Message

Gaetano Giunta

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

Luigi Spagnolo

Tuesday 26 May 2009 2:10:57 am

Thank you very much for your precious suggestions. :)

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu