I'm using EntityFieldQuery in an attempt to query for specific field values (dates in an event db) then perform some analysis on them.
I've gotten far enough to correctly query and return specific nodes as a result but am getting stuck on field_get_items - I can't get the actual field values out. It appears I am not passing the necessary parameters of the bundle to the function.
Where am I going wrong?
Drupal throws this error on the last line of code starting w $output "EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7734 of /home4/xxxxx/public_html/xxxxxx/xxxxxx/includes/common.inc)."
Here's my code:
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'event')
->propertyCondition('status', 1)
->fieldCondition('field_date', 'value', 'NULL', '!=');
$result = $query->execute();
if (isset($result['node'])) {
$stories = $result['node'];
// Get all fields attached to a given node type
$fields = field_info_instances('node', 'event');
// Get id of body field
$field_id = $fields['field_date']['field_id'];
//echo $field_id... testing, works;
// Attach a field of selected id only to get value for it
echo field_view_field('node', $stories, 'field_date');
//Get values of our node field
$output = field_get_items('node', $stories, 'field_date');
}
I get an error on the last step