Created
June 18, 2013 15:13
-
-
Save sanguis/5806200 to your computer and use it in GitHub Desktop.
EntiryFieldQuery basic page that outputs "team" type nodea teaser views
This file contains hidden or 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 | |
/** | |
* Implements hook_menu(). | |
*/ | |
function team_menu() { | |
$items['team'] = array( | |
'title' => t('Team'), | |
'page callback' => 'team_page', | |
'access arguments' => array('access content'), | |
'type' => MENU_NORMAL_ITEM, | |
); | |
return $items; | |
} | |
function team_page() { | |
$query = new EntityFieldQuery(); | |
$query | |
->entityCondition('entity_type', 'node') | |
->propertyCondition('status', 1) | |
->entityCondition('bundle', 'team') | |
; | |
$result = $query->execute(); | |
if (count($result) > 0) { | |
$nids = array_keys($result['node']); | |
$output = node_view_multiple(node_load_multiple($nids), 'teaser'); | |
} | |
else { | |
$output['#prefix'] = "<h2>" . t('Not Found') . "</h2><p>" . t('No team members found') . "</p>"; | |
} | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment