Is there a way to open directly the page in which a record appears?
Example:
function index($id){
$this->paginate = array(
'limit'=>12,
'page' => ????
);
$items = $this->Item->paginate();
/**
How can i calculate the page number, by the $id?
*/
}
If you got the ID, and you are auto_incrementing the ID in your database, you can count row before this ID:
$nbRow = $this->Item->find('count', array('conditions' => array('id <=' => $id))) ;
Then to find the page, you just have to divide (int division) by the number of item per page:
$page = ceil($nbRow / 12) ; // 12 or whatever item per page you have