function index() { global $router; $post = new BlogPost(); $posts = $post->getMostRecent(5); $data = array(); foreach ($posts as $post) { $data[] = (object) array('url' => $router->urlFor('Blog', 'readPost', array('year' => $post->created->format('Y'), 'month' => $post->created->format('m'), 'slug' => $post->slug)), 'title' => $post->title, 'numComments' => 0); } $this->render('home', array('posts' => $data)); }