Bellow is the code for a custom module that parses json to ios devices. The thing is on my drupal page I've created a node hierarcy using "nodehierarcy" module. I've got two types of custom contents - phones and events. For each phone I have a list of events which I want to parse. The problem with the code below is that it's parsing all of the jobs instead of categorizing them per device. The json output url is: "xyz.com/job/json". But I want something like xyz.com/?q=node/4/json
, node 4 representing a phone. Any ideas?
function job_menu() {
$items =array();
$items['job/json'] = array(
'title' => 'Json callback',
'page callback' => 'message_json_page',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
function message_json_page(){
$sql = "SELECT n.nid , n.title as name FROM {node} n
WHERE n.status = 1 and n.type = :type";
$result = db_query($sql, array(':type'=>'job'))->fetchAll();
$json_value = json_encode($result);
print $json_value;
}