Created
August 3, 2014 00:05
-
-
Save felipesr/9bd8bdb38fddbac7c4f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ArtigosController extends AppController { | |
//public $scaffold; | |
public $uses = array('Artigo'); | |
public function listar($page) { // Busca todas as notícias | |
$this->Artigo->page = $page; | |
$params = array( | |
'fields' => array('Artigo.nome', 'Artigo.data', 'Artigo.url'), | |
'order' => array('Artigo.data' => 'DESC'), | |
'limit' => 10, | |
'page' => $page | |
); | |
$this->paginate = $params; | |
// Roda a consulta, já trazendo os resultados paginados | |
$artigos = $this->paginate('Artigo'); | |
//$artigos = $this->Artigo->find('all', $params); | |
// Manda para a View | |
$this->set('artigos', $artigos); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment