Created
March 26, 2012 04:40
-
-
Save eads/2202964 to your computer and use it in GitHub Desktop.
Roufa's random sorting
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 | |
$results = array(); | |
$terms = array(1, 2); | |
foreach ($terms as $tid) { | |
$result = NULL; | |
$query = new EntityFieldQuery; | |
$query | |
->entityCondition('entity_type', 'node') | |
->fieldCondition('field_event_type', 'tid', $tid, '=') | |
->propertyOrderBy('created', 'DESC') | |
->pager(10); | |
$result = $query->execute(); | |
if ($result) { | |
$results += entity_load('node', array_keys($result['node'])); | |
} | |
} | |
shuffle($results); | |
$sliced = array_slice($results, 0, 10); | |
dpm($sliced); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment