Created
March 7, 2014 12:28
-
-
Save renebakx/9410575 to your computer and use it in GitHub Desktop.
EntityFieldQuery
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 | |
// build from drupal_get_query_parameters(); | |
$filterQuery = array('news', 'blog', 'article'); | |
// build query | |
$query = new EntityFieldQuery(); | |
$query->entityCondition('entity_type', 'node'); | |
$query->propertyCondition('type', 'page'); | |
$query->propertyCondition('status', 1); | |
$query->fieldCondition('field_page_type', 'value', $filterQuery, 'in'); | |
$query->propertyOrderBy('title', 'ASC'); | |
$results = $query->execute(); | |
// build renderable items | |
$pages = array(); | |
if (isset($results['node'])) { | |
$nodes = entity_load('node', array_keys($results['node'])); | |
$pages = entity_view('node', $nodes, 'teaser'); | |
} | |
return $pages; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment