Last active
November 2, 2019 01:53
-
-
Save robdecker/c1dfae932bb20f240416 to your computer and use it in GitHub Desktop.
[Load a field from a node] #d7
This file contains hidden or 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
/** | |
* Get a field from a node object. | |
* Sometimes the node has a language identifier on the field, sometimes it does | |
* not. | |
*/ | |
function _THEME_NAME_get_field($node, $field_name) { | |
if (isset($node->{$field_name}[0])) { | |
return $node->{$field_name}; | |
} | |
else { | |
return field_get_items('node', $node, $field_name, ''); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment