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.




Thursday, April 24, 2014

Drupal - Creating an API without losing your soul.

Drupal services https://drupal.org/project/services is a one stock module for exposing every aspect of a drupal site's functionality as a service for multiple device consumption.
Services views module https://drupal.org/project/services_views enables site builders to expose their views (Drupal query builder) as a service making a developer build an entire API without writing a single line of code. If a developer wants custom service endpoints, they just create a module and use hook_services_resources() to get that endpoint up.
Other devices can now make requests and push content or fetch content to the API. All the authentication methods are also supported. Session authentication exists by default but turned off. A developer can enable that or use http basic authentication https://drupal.org/project/services_basic_auth or Oauth authentication https://drupal.org/project/oauth .

"Lazy Development" - Java, .NET, and PHP

Microsoft started the process of making developers click around to get things done with their superb IDE. An idea which was frowned upon by coding junkies because they think software development should always be rocket surgery. Java IDEs had no option than follow the trend with NetBeans and JDeveloper Studio (the ones I have been using). The multipurpose Dreamweaver is also good but have been overshadowed by the other specialized IDEs. In the PHP arena Drupal is the only software I have seen and used which comes close to letting PHP developers develop with ease the way .NET and Java developers develop do with their IDEs.
Drupal is a monstrous sort of software. It is more developer friendlier than non-developer friendly. It treats every content as an organized entity so that specific parts of the content can be displayed when the need arises. Unlike other CMSes which let users just dump content here and there once they have it. If someone has used the non-developer friendly Wordpress and Joomla CMSes before and they come to Drupal, they find themselves in a maze.
Whenever I am building complex web apps, my go to software is Drupal. If is it not complex enough then Joomla all the way. It is all about using the right tool for the right job.
I will go through a lot of hell if I were to use Joomla or Wordpress to build APIs for multiple devices consumption.  I mean native apps consuming content, not just device browsers consuming content or responsive web. Using Drupal for such a task is super easy since version 5 and the next version of Drupal, 8, comes with this functionality in core. One doesn't have to install module before they can expose content as a service for multiple devices to consume.
.NET and Java developers can easily build APIs fast by clicking around again in the IDE's specified above.