Comments on: Pagination with custom find types in CakePHP /cakephp/pagination-with-custom-find-types-in-cakephp/ A glimpse at a coder's troubled mind Sun, 30 May 2010 17:13:26 -0300 http://wordpress.org/?v=2.9.2 hourly 1 By: Pagination with custom find types in CakePHP | Coding My Thoughts | Source code bank/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-1485 Pagination with custom find types in CakePHP | Coding My Thoughts | Source code bank Fri, 30 Apr 2010 00:04:11 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-1485 [...] the original post: Pagination with custom find types in CakePHP | Coding My Thoughts If you enjoyed this article please consider sharing [...] [...] the original post: Pagination with custom find types in CakePHP | Coding My Thoughts If you enjoyed this article please consider sharing [...]

]]>
By: adnan/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-440 adnan Mon, 25 Jan 2010 11:03:23 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-440 @ohcibi, calling the $paginator->options(array(‘url’ => $this->passedArgs)); in the view is never a good idea, though it's suggested in the Cake Book. Never call it.I have found a better way for advance pagination with custom/derived fields in a simple and easy method.Here is the details in the blog post: http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/Hope you'll find it helpful.Thanks @ohcibi, calling the $paginator->options(array(‘url’ => $this->passedArgs)); in the view is never a good idea, though it’s suggested in the Cake Book. Never call it.

I have found a better way for advance pagination with custom/derived fields in a simple and easy method.

Here is the details in the blog post: http://abcoder.com/php/cakephp/cakephp-advanced-pagination-sort-by-derived-field/

Hope you’ll find it helpful.

Thanks

]]>
By: mariano.iglesias [Member]/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-8 mariano.iglesias [Member] Sun, 27 Dec 2009 07:58:00 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-8 @Giuliano: You are wrong. You CAN do that. Try it. @Giuliano: You are wrong. You CAN do that. Try it.

]]>
By: Giuliano [Visitor]/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-7 Giuliano [Visitor] Sat, 26 Dec 2009 11:45:00 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-7 This isn't a very good method. It's clean but doesn't allow you to pass a variable to your paginate conditions, such as:<br /> <br /> $posts = $this->Post->find('all', array(<br /> 'conditions' => <br /> array('Post.category' => $id),<br /> array('Post.published' => 1),<br /> 'order' => array('Post.created' => 'desc')<br /> ));<br /> <br /> would not work with this method This isn’t a very good method. It’s clean but doesn’t allow you to pass a variable to your paginate conditions, such as:

$posts = $this->Post->find(‘all’, array(
‘conditions’ =>
array(‘Post.category’ => $id),
array(‘Post.published’ => 1),
‘order’ => array(‘Post.created’ => ‘desc’)
));

would not work with this method

]]>
By: Leonardo Jorge [Visitor]/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-6 Leonardo Jorge [Visitor] Mon, 19 Oct 2009 08:11:00 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-6 This implematation looks like Named Scope Behavior<br /> <br /> http://github.com/joelmoss/cakephp-namedscope This implematation looks like Named Scope Behavior

http://github.com/joelmoss/cakephp-namedscope

]]>
By: Jesús Ángel [Visitor]/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-5 Jesús Ángel [Visitor] Thu, 08 Oct 2009 17:43:00 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-5 Be careful.<br /> <br /> Original find method has four args, but this one only has two.<br /> <br /> You have to add the order and recursive params or you will loose them Be careful.

Original find method has four args, but this one only has two.

You have to add the order and recursive params or you will loose them

]]>
By: Jesús Ángel [Visitor]/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-4 Jesús Ángel [Visitor] Thu, 08 Oct 2009 17:41:00 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-4 ¡Be careful!<br /> <br /> Model->find() has four args:<br /> <br /> $type, $options = array(), $order = null, $recursive = null<br /> <br /> But the example's find method only has two args, so you loose the other ones.<br /> <br /> <br /> Change:<br /> public function find($type, $options = array(), $order = null, $recursive = null)<br /> <br /> return parent::find($type, $options, $order = null, $recursive = null);<br /> ¡Be careful!

Model->find() has four args:

$type, $options = array(), $order = null, $recursive = null

But the example’s find method only has two args, so you loose the other ones.

Change:
public function find($type, $options = array(), $order = null, $recursive = null)

return parent::find($type, $options, $order = null, $recursive = null);

]]>
By: Pedro [Visitor]/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-3 Pedro [Visitor] Tue, 25 Aug 2009 09:48:00 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-3 alguna idea mariano...?! alguna idea mariano…?!

]]>
By: Pedro [Visitor]/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-2 Pedro [Visitor] Fri, 21 Aug 2009 06:26:00 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-2 hola mariano!<br /> <br /> Took about a week looking for information on how to customize the URL from the paginate method. <br /> <br /> I found several things but nothing really useful, and the truth that I am a little off and I saw that you work with CakePHP. <br /> The issue is that I have to keep the urls of my site just because they are indexed in Google and the SEO and the structure of URLs is very well composed. For example, I have a url like http:miproyecto.loc/padres which I included in a routes.php enroute to do the following: <br /> <br /> Router::connect ('/padres', array('controller'=>'contenidos', 'action'=>'listado','parameters'=>'listar_todo'));<br /> <br /> and when to call the method paginate: <br /> <br /> $array_contenidos = $this->paginate('Contenido',$criterios);<br /> <br /> the url that the paginate method looks like: <br /> <br /> http://miproyecto.loc/contenidos/listado/page:2 <br /> but I want to get <br /> http:miproyecto.loc/padres-2. <br /> <br /> I tried everything and I managed to change the urls generated by the method of pagination In the function link of the helper paginator.php I have included the following lines <br /> <br /> /* APAÑO PARA PAGINACION */<br /> $seccion_url = explode("-",$this->params['url']['url']);<br /> $url = 'http://'.DOMINIO.'/'.$seccion_url[0].'-'.$url['page'];<br /> /* FIN APAÑO PARA PAGINACION */<br /> return $this->{$obj}->link($title, $url, $options);<br /> <br /> But now I have the problem to put in all the rules (manually) routes.php (which I can die because there are thousands) <br /> Router:: connect ( '/ preconception-2', array ( 'controller' => 'content', 'action' => 'list', 'parameters' =>' listar_todo ',' named '=> array (' page '=> 2)));<br /> <br /> I hope you can help me and give some advice or instructions.<br /> <br /> Thx<br /> <br /> Muchas gracias y saludos desde España!<br /> <br /> hola mariano!

Took about a week looking for information on how to customize the URL from the paginate method.

I found several things but nothing really useful, and the truth that I am a little off and I saw that you work with CakePHP.
The issue is that I have to keep the urls of my site just because they are indexed in Google and the SEO and the structure of URLs is very well composed. For example, I have a url like http:miproyecto.loc/padres which I included in a routes.php enroute to do the following:

Router::connect (‘/padres’, array(‘controller’=>’contenidos’, ‘action’=>’listado’,'parameters’=>’listar_todo’));

and when to call the method paginate:

$array_contenidos = $this->paginate(‘Contenido’,$criterios);

the url that the paginate method looks like:

http://miproyecto.loc/contenidos/listado/page:2
but I want to get
http:miproyecto.loc/padres-2.

I tried everything and I managed to change the urls generated by the method of pagination In the function link of the helper paginator.php I have included the following lines

/* APAÑO PARA PAGINACION */
$seccion_url = explode(“-”,$this->params['url']['url']);
$url = ‘http://’.DOMINIO.’/’.$seccion_url[0].’-’.$url['page'];
/* FIN APAÑO PARA PAGINACION */
return $this->{$obj}->link($title, $url, $options);

But now I have the problem to put in all the rules (manually) routes.php (which I can die because there are thousands)
Router:: connect ( ‘/ preconception-2′, array ( ‘controller’ => ‘content’, ‘action’ => ‘list’, ‘parameters’ =>’ listar_todo ‘,’ named ‘=> array (‘ page ‘=> 2)));

I hope you can help me and give some advice or instructions.

Thx

Muchas gracias y saludos desde España!

]]>
By: ohcibi [Visitor]/cakephp/pagination-with-custom-find-types-in-cakephp/comment-page-1/#comment-1 ohcibi [Visitor] Mon, 13 Jul 2009 08:49:00 +0000 /1/pagination-with-custom-find-types-in-cakephp/#comment-1 The urls, which are generated by the paginatorhelper are not e.g. controller/action/page:3 but controller/action/name_of_find_type/page:3. <br /> <br /> If $paginator->options(array('url' => $this->passedArgs)); is called in the view then after every click on a paginator helper link theres one name_of_find_type more in the url. The urls, which are generated by the paginatorhelper are not e.g. controller/action/page:3 but controller/action/name_of_find_type/page:3.

If $paginator->options(array(‘url’ => $this->passedArgs)); is called in the view then after every click on a paginator helper link theres one name_of_find_type more in the url.

]]>