Problem with pagination links with routing
i need to route all /home/college
, /home/school
etc to thehome
controller's index
action, with the following prototype.
functi开发者_StackOverflow社区on index($type="school"){
...
}
below is my routing definition
Router::connect('/home/:type',array('controller'=>'home','action'=>'index'),array('pass'=>array('type'),'type'=>'(college)|(school)'));
i am also using pagination inside it. But when i generate the next and previous links it's like below
http://mysite.com/home/index/school/page:2
How can i remove the 'index' from the link?
I'm not sure if you will have much luck removing index
as it is the default action.
However, I'm surprised your route works as mode
is undefined.
Router::connect('/home/:type',
array('controller'=>'home', 'action'=>'index'),
array('pass'=>array('type'), 'type'=>'(college|school)'));
Check out CakePHP Routes Configuration.
Alternatively, you could just create a 'dummy' home
action, and call index
with it.
function home($type="school"){
$this->setAction('index',$type);
}
http://api13.cakephp.org/class/controller#method-ControllersetAction
精彩评论