/** * Implements hook_menu(). */ function mymodule_menu() { $items = array(); $items['custom/api/dataset/%'] = array( 'page callback' => 'mymodule_custom_dataset_api', 'page arguments' => array(3), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); return $items; } /** * Custom API endpoint. */ function mymodule_custom_dataset_api($dataset_id) { // Get the dataset $node = node_load($dataset_id); if (!$node) { drupal_json_output(array('error' => 'Dataset not found')); drupal_exit(); } // Build a basic response $response = array( 'success' => TRUE, 'result' => array( 'id' => $node->nid, 'title' => $node->title, ) ); // Add the DOI field if (isset($node->field_doi)) { $doi_field = field_get_items('node', $node, 'field_doi'); if ($doi_field) { $response['result']['doi'] = $doi_field[0]['value']; } } drupal_json_output($response); drupal_exit(); } awchild | RCDS Data Repository
awchild

175 Datasets

0 Groups

User since 11/10/2020

Idaho EPSCoR GEM3 Data Manager

User is not a member of any group.

Tags

awchild's content