Created
August 29, 2014 15:50
-
-
Save slucero/cee51deacb4077a79f8e to your computer and use it in GitHub Desktop.
Drupal EntityFieldQuery Example
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
<?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