Created
March 15, 2014 14:28
-
-
Save mazewei/9568147 to your computer and use it in GitHub Desktop.
extension for drupal module DrupalGap. Manipulate the webservice to submit also term names, not only term ids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO backend for configure taxonomy ref fields | |
/** | |
* Implements hook_services_request_postprocess_alter(). | |
*/ | |
function bdi_tax_tid_services_request_postprocess_alter($controller, $args, &$result) { | |
if ($controller['callback'] === '_node_resource_retrieve') { | |
$fieldnames = array(); | |
//your fieldnames here | |
$fieldnames = array(field_herausgeber_autor,field_keywords,field_zeitschriftentitel); | |
foreach ($result as $key => $value) { | |
foreach($fieldnames as $fieldnames_key => $fieldnames_value) { | |
$current_field_name = $fieldnames_value; | |
if ($key == $fieldnames_value) { | |
$keywords = $value; | |
foreach ($keywords['und'] as $key_term => $value_term) { | |
$termname = taxonomy_term_load($value_term['tid']); | |
//dynamically | |
if(!isset($add_to_array)) { | |
$add_to_array = array(); | |
} | |
$add_to_array[$key]['und'][$key_term]['value'] = $termname->name; | |
$add_to_array[$key]['und'][$key_term]['tid'] = $termname->tid; | |
} | |
} | |
} | |
} | |
foreach ($add_to_array as $add_to_array_key => $add_to_array_value) { | |
foreach($result as $key2 => $value2) { | |
if($key2 == $add_to_array_key) { | |
$result->$key2 = $add_to_array_value; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mazewei and @ice432cube, this feature now works in the latest development snapshots of the DrupalGap module and SDK. Otherwise it will become available in the next recommended releases.