Fix for Fix for Fix for Fix for Fix for retrieve field result from node

  1. // Example code to return the data for node 15 -- a change_request content_type.
  2. // The manager field uses the CCK user_reference field
  3. // The assigned is just a text field for comparison
  4.  
  5.   $myentity = new stdClass();
  6.   $myentity->id = 15;
  7.   $myentity->bundle = 'change_request';
  8.   field_attach_load('node', array($myentity->id => $myentity));
  9.   $manager = $myentity->field_request_manager['und'][0];
  10.   $assigned = $myentity->field_request_assigned['und'][0];
  11.  
  12.   /* Example of what is returned
  13.    * $manager = array('uid' => 17);
  14.    * $assigned = array('value' => 'bob', 'format' => NULL, 'safe_value' => 'bob');
  15.  
  16.    * Need to be able to support any content_type and field
  17.    * Need a way to return just the field value
  18.    * This code snippet shows the field data is indexed in an array by $languagekey ,
  19.       then $delta and then in an array defined by the data type.
  20.    * There must be a function or API to format the result and just return the value.  
  21.    */

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.