0

I have the following two routes which make the url /posts/recent show page 1 of the recent filter on index method of my posts controller and also allow paging like: /posts/recent/page:2 by using the * on the next route. As you can see I call page 1 on the first route so that I don't get duplicate urls for page 1.

Router::connect('/posts/recent', array('controller'=>'posts','action'=>'index','filter'=>'recent', 'page' => 1), array('pass'=>array('filter')));


Router::connect('/posts/recent/*', array(
  'controller' => 'posts', 'action' => 'index', 'filter'=>'recent'), array(
    'named' =>array('page' => '[\d]+'),
     'pass'=>array('filter')
  )
);

However I would like to make it so that named params do this instead:

/posts/recent/page/2 but how do I do it?

I've looked around the docs but don't seem to see anything about doing this...

Also is it possible to turn off named parameters in favour of query strings?

I'm using CakePHP 2.1 if it matters.

1 Answer 1

0

Perhaps with Router::connectNamed()?

http://book.cakephp.org/2.0/en/development/routing.html

1
  • What does that do? As from the docs it looks like it just adds the named parameter to the route which is what it's already doing automatically... am I misunderstanding?
    – Cameron
    May 4, 2012 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.