Wednesday, May 30, 2012

Problem with Pagination and Routes

Hi guys, I have this route:

Router::connect('/comparacao/:id/:slug', array('controller' =>
'products', 'action' => 'comparison'),
array('pass' => array('id', 'slug'))
);

When I access below url, it work successfully

http://myproject/comparacao/6315/Lata-DVD-O-Fantastico-Jaspion-Vol-1-5-DVDs

I am performing a query using PaginatorComponent (through 'model_id',
in this case 6315), when I click in a link generated by
<?php echo $this->Paginator->numbers(); ?>

I go for this url:

http://myproject/products/comparison/6315/Lata-DVD-O-Fantastico-Jaspion-Vol-1-5-DVDs/page:2

and I get this error:

Error: The requested address '/products/comparison/6315/Lata-DVD-O-
Fantastico-Jaspion-Vol-1-5-DVDs/page:2' was not found on this server.

I have to active named params for my route (like
http://book.cakephp.org/2.0/en/development/routing.html#controlling-named-parameters)?

I have tried activate named params through:
Router::connectNamed(false, array('default' => true));,
Router::connectNamed(array('page'), array('default' => false, 'greedy'
=> false)); and others, but I have failed.

What I really would like to use route from paginator as I used one
time in Cake 1.3 (http://stackoverflow.com/questions/5033633/cakephp-
custom-route-pagination
), just adding /2 in the end of route (2 is
number of page), but I have tried it in Cake 2 and I think that just
using Custom Routing Class.

Someone can help me? Thank you.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: