Created
May 26, 2013 11:09
-
-
Save flashvnn/5652475 to your computer and use it in GitHub Desktop.
Get field data without load node
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
$field_name = 'field_banner_media'; | |
$field_info = field_info_field($field_name); | |
$field_id = $field_info['id']; | |
$nids = array($banner_top); | |
$sql = 'SELECT * FROM {node} WHERE nid IN (:nids)'; | |
$nodes = db_query($sql, array(':nids' => $nids))->fetchAllAssoc('nid'); | |
field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id)); | |
$field_banner = field_get_items('node', reset($nodes), $field_name); | |
$field_banner_url = isset($field_banner[0]['uri'])? file_create_url($field_banner[0]['uri']): NULL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment