Skip to content

Instantly share code, notes, and snippets.

@rbk
Created November 23, 2016 13:09
Show Gist options
  • Save rbk/98d38090e45252e797a12156fde4ff4c to your computer and use it in GitHub Desktop.
Save rbk/98d38090e45252e797a12156fde4ff4c to your computer and use it in GitHub Desktop.
Here is a simple example to load up some nodes of type event for the month of March, looking up information of a field type datetime called 'field_date':
<?php
<?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