Salutations,
Je bloque un peu sur un petit truc, et je cherche à paginer les articles qui appartiennent à telle ou telle catégorie, mais je ne sais pas trop comment faire :/
Mon controller :
function show_category($category){
$this->loadModel('Category');
$d'category'] = $this->Category->find('first', array(
'conditions' => array('slug' => $category),
'contain' => array('Post' => array('Media', 'order' => 'Post.created ASC', 'conditions' => array('Post.online = 1', 'Post.created <= NOW()')))
));
$this->set($d);
}
En gros comment paginer ce find first (qui contient d'autres array !) ou paginer l'array en lui même :S
Je vous donne le debug de $d'category'] :
array(
'Category' => array(
'id' => '1',
'name' => 'audio',
'slug' => 'audio',
'count' => '2',
'link' => array(
'controller' => 'posts',
'action' => 'show_category',
'slug' => 'audio'
)
),
'Post' => array(
(int) 0 => array(
'id' => '1',
'name' => 'Mon premier article',
'slug' => 'mon-premier-article',
'description' => '<p>Ma description.</p>',
'media_id' => '394',
'created' => '1995-11-11 16:35:00',
'online' => '1',
'thumbs' => '1',
'CategoriesPost' => array(
'id' => '148',
'post_id' => '1',
'category_id' => '1'
),
'Media' => array(
(int) 0 => array(
'id' => '235',
'ref' => 'Post',
'ref_id' => '1',
'file' => 'Uploads/Posts/2012/Nov/1/223ug78u.jpg',
'position' => '0',
'show' => '0',
'filef' => 'Uploads/Posts/2012/Nov/1/223ug78u_%dx%d.jpg'
),
(int) 1 => array(
'id' => '236',
'ref' => 'Post',
'ref_id' => '1',
'file' => 'Uploads/Posts/2012/Nov/1/590544_ressorts_colores_d_isolement_sur_le_blanc.jpg',
'position' => '0',
'show' => '0',
'filef' => 'Uploads/Posts/2012/Nov/1/590544_ressorts_colores_d_isolement_sur_le_blanc_%dx%d.jpg'
),
(int) 2 => array(
'id' => '394',
'ref' => 'Post',
'ref_id' => '1',
'file' => 'Uploads/Posts/2012/Nov/1/atika_atikawa.jpg',
'position' => '0',
'show' => '0',
'filef' => 'Uploads/Posts/2012/Nov/1/atika_atikawa_%dx%d.jpg'
)
)
),
(int) 1 => array(
'id' => '2',
'name' => 'Mon second article',
'slug' => 'mon-second-article',
'description' => '<p>Ma desc...</p>',
'media_id' => '227',
'created' => '2012-10-11 17:11:00',
'online' => '1',
'thumbs' => '1',
'CategoriesPost' => array(
'id' => '141',
'post_id' => '2',
'category_id' => '1'
),
'Media' => array(
(int) 0 => array(
'id' => '227',
'ref' => 'Post',
'ref_id' => '2',
'file' => 'Uploads/Posts/2012/Nov/2/co.jpg',
'position' => '0',
'show' => '0',
'filef' => 'Uploads/Posts/2012/Nov/2/co_%dx%d.jpg'
),
(int) 1 => array(
'id' => '241',
'ref' => 'Post',
'ref_id' => '2',
'file' => 'Uploads/Posts/2012/Nov/2/ET.jpg',
'position' => '0',
'show' => '0',
'filef' => 'Uploads/Posts/2012/Nov/2/ET_%dx%d.jpg'
)
)
)
)
)
Il serait préférable de ne pas perdre l'index Media en faisant la pagination, car je l'utilise pour mon image de page à la une :S
Merci d'avance :)