Reputation: 391
I have the following code in Drupal to get the list of nodes that match certain conditions:
function get_failgames($form, &$form_state) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'game_results')
->propertyCondition('status', 1)
->fieldCondition('field_division', 'tid', (array) $form_state['values']['division'])
->fieldCondition('field_ft_home_team_goals', 'value', 5, '=')
->addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query->execute();
dpm($result);
}
Now I want to get one or more fields of those nodes. How should I do this? Load each single node?
Thanks!
Upvotes: 0
Views: 251
Reputation: 485
You need to use node_load_multiple()
function & pass array_keys($result['node'])
as an argument to the same. Please check sample code below:
function get_failgames($form, &$form_state) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'game_results')
->propertyCondition('status', 1)
->fieldCondition('field_division', 'tid', (array) $form_state['values']['division'])
->fieldCondition('field_ft_home_team_goals', 'value', 5, '=')
->addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query->execute();
$nodes = node_load_multiple(array_keys($result['node']));
dpm($result);
dpm($nodes);
}
Upvotes: 2