pmaluf 0 Denunciar post Postado Abril 7, 2012 Pessoal, Como eu preencho uma tabela no meu home.ctp? Por exemplo, mostrar os últimos 10 posts do meu blog? Preciso importar o model da tabela Posts?? Não faço idéia. :/ Obrigado. Compartilhar este post Link para o post Compartilhar em outros sites
pmaluf 0 Denunciar post Postado Abril 7, 2012 Consegui!!! Precisa usar elements!! Controller: public function index() { $this->post->recursive = 0; $this->set('posts', $this->paginate()); $posts = $this->paginate(); if (isset($this->params['requested'])) { return $posts; } } Element: <?php $posts = $this->requestAction('posts/index/sort:created/direction:asc/limit:5'); ?> <?php debug($posts); ?> <table cellpadding="0" cellspacing="0"> <?php foreach ($posts as $post): ?> <tr> <td><?php echo h($post['post']['id']); ?> </td> <td><?php echo h($post['post']['post_name']); ?> </td> <td><?php echo h($post['post']['desc_post']); ?> </td> </tr> <?php endforeach; ?> </table> <p> Compartilhar este post Link para o post Compartilhar em outros sites