I need create three random links to other posts, in my post view function.
Controller:
$random = $this->Post->find('all', array(
'order' => 'rand()',
'limit' => 3,
'conditions' => array('Post.status' => 'ok')
));
But i do not know, how to write a foreach for this.
Thanks
It will depend on the fields you get back from Post. I would change the controller code just slightly to this:
Then in the view you cycle through them in the foreach:
Be sure to update the fields in the HTML link to those that conform to what ever comes back from the Post model.