Skip to content

Instantly share code, notes, and snippets.

@slucero
Created August 29, 2014 15:50
Show Gist options
  • Save slucero/cee51deacb4077a79f8e to your computer and use it in GitHub Desktop.
Save slucero/cee51deacb4077a79f8e to your computer and use it in GitHub Desktop.
Drupal EntityFieldQuery Example
<?php
$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'event')
->propertyCondition('status', 1)
->fieldCondition('field_date', 'value', array('2011-03-01', '2011-03-31'), 'BETWEEN')
->fieldOrderBy('field_date', 'value', 'ASC')
->execute();
$nodes = node_load_multiple(array_keys($entities['node']));
$views = node_view_multiple($nodes, 'teaser');
$build['#nodes'] = $views['nodes'];
$build['#theme'] = 'whatever';
return $build;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment