7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » randomized Arraylist. (SS3)
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 298 Views |
-
randomized Arraylist. (SS3)

13 December 2012 at 10:54pm
Hi, how can i randomize a ArrayList? This is my Code:
public function ImpressionsInRandomOrder($__count = 15) {
$homepagePercent = 0.8;
$homepageCount = (int) round($__count * $homepagePercent);
$currentCount = $__count - $homepageCount;$_home = ImpressionObject::get()->filter(array('PageID' => '1'))->sort('RAND()')->limit($homepageCount);
$_current = ImpressionObject::get()->filter(array('PageID' => $this->ID))->sort('RAND()')->limit($currentCount);$_merge = new ArrayList();
$_merge->merge($_home);
$_merge->merge($_current);
$_merge->sort('RAND()'); <-- this don't goreturn $_merge;
}
| 298 Views | ||
|
Page:
1
|
Go to Top |

