Helper to get the raw value of a node field? I wonder if something "core" already exists that gives me the raw value of a field inside a node. For that matter I wrote this little helper, but it seems too strange not to be able to do it with a core function:

function mymodule_get_node_field($node, $name, $lang = 'und', $key = 'value') {

  if (substr($name, 0, 6) != 'field_') {
    $name = "field_{$name}";
  }

  if (!is_object($node) || !isset($node-&gt;{$name}) || !isset($node-&gt;{$name}[$lang])) {
    return null;
  }

  return $node-&gt;{$name}[$lang][0][$key];
}
The only thing I know is field_get_items().

Your function makes a lot of assumptions that don't work for a core function.


Not all fields are prefixed with field_, only those created through the UI. body for example not.
Some fields have multiple values, your function only returns the first.


If you want a function that makes these assumptions, you could write a simple wrapper for field_get_items() that takes care of that.