Wednesday, April 30, 2014

Drupal Services Views - Unformatted List Display Format

Services views module empowers developers to expose their views(queried data) as web service endpoints for GET requests. When creating the view, however, the Unformatted List display format can create a nightmare for the developer.
The reason is selecting Unformatted List with teasers and full posts selected creates an unfriendly endpoint data structure which won't change even if the user changes the Display Format to Table or anything else in the view editing screen.
To be on the safer side selecting Unformatted List should always go with selecting titles, titles(linked) or fields instead of the teasers or full posts.
 One might ask what if the developer wants comments related to the post in the data? Well it is simpler and best to create a view for comments with the node id (Nid) as an exposed filter so that the app makes that request separately from the request to the node itself.
So http://host/apimachinename/views/viewsmachinename?nid=nodeID will give you comments related to the post which is fine.




No comments:

Post a Comment