One way to do this is to get a random instruction in the init controller function and assign it to a private variable. We add the getRandomStatement function to retrieve a random instruction:
class Page_Controller extends ContentController { private $randomStatement; public function init() { parent::init(); $this->randomStatement = Statement::get()->sort('RAND()')->limit(1)->first(); } public function getRandomStatement() { return $this->randomStatement; } }
3dgoo source share