Skip to main content


Showing posts from January 26, 2012

Getting the node body with the index method call - services module drupal 7

The api call to the index method i.e. http://domain/?q=endpoint/node returns an index of nodes (this call can be paged too. e.g. http://domain/?q=endpoint/node.json&page=2&pagesize=10 ). It does not return the node body with it. node body is in a separate table (field_data_body) table I needed the index to contain the body too, which I can parse and display as a feed on my application. I was looking at "services views" module but could not it to work. So I hacked around and played around with the node_resource's index method to respond back with the join of the two tables and thus containing the node body for a given node id. Code snippet: function _node_resource_index($page, $fields, $parameters, $page_size) {   module_load_include('inc', 'services', 'services.module');   $start = (($page)-1)*$page_size;   $query = db_select('node', 'n');   $query->join('field_data_body', 'u', 'n.nid =

services module Drupal 7. Getting the JSON server to work.

I needed to use my drupal site as web service to serve my android/iphone app. The responses had to be in json format. I knew about services module which can do the needful with json server enabled. However for drupal 7, the documentation said that json server is built into the services core. The documentation is JUST AWFUL Anyways cutting the shit, here's how I got stuff working : install services 3 grab spyc library (this was the most irritating part) from the download, copy spyc.php and paste it in modules/service/servers/rest/lib enable services module enable "rest server" module at this point Services may not appear in Structure. Run cron and Update script. go to structure->services->add give a unique name, an endpoint name (mine is "api") so in the textbox, just write "api" nothing else save and then open it to edit in the resources, check "node" permissions for &quo