Friday, June 29, 2012

Re: Routes with slugs, pagination problem

Router::connect(
'/:slug',
array(
'controller' => 'categories',
'action' => 'view'
),
array(
'slug' => '[-a-z0-9]+',
'pass' => array('slug')
)
);
Router::connect(
'/:slug/:page',
array(
'controller' => 'categories',
'action' => 'view'
),
array(
'slug' => '[-a-z0-9]+',
'page' => '[0-9]+',
'pass' => array('slug')
)
);

And I had to put the following in AppController::beforeFilter when I
upgraded to 2.x:

if (isset($this->request->params['page']))
{
$this->request->params['named']['page'] = $this->request->params['page'];
}

On Thu, Jun 28, 2012 at 6:10 PM, Ovidiu Marinoiu
<ovidiu.marinoiu@gmail.com> wrote:
> Hello,
>
> I have created a route which looks like this Router::connect('/:slug',
> array('controller' => 'categories', 'action' => 'view'), array('pass' =>
> array('slug')));
>
> Until here, everything works okey, visiting the
> link http://example.com/animals-and-pets, works perfect.
>
> On this page I have a pagination and this gives me e big problem, the links
> for the pages, are generating wrong, like
> this: http://example.com/categories/view/animals-and-pets/page:2.
>
> The result that I want to obtain is http://example.com/animals-and-pets/2.
>
> Thanks for your help in advance!
>
>
> --
> 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

--
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: