我对CakePHP 2.x Custom Route with Arguments提出了类似的问题,我希望将该参数用作我的变量之一。
(域/ PARAM /控制器/动作/ PARAM)
Router::connect(
'/:sitecode/:controller/:action/*',
array(),
array('sitecode' => '[A-Z]{20}', 'persist' => array('sitecode'))
);
上面的代码不起作用,它仍然将:sitecode
视为控制器,并将:controller
视为动作。我做错了什么?
我以后如何从我的代码访问:sitecode
?
Customize your route like this:
Router::connect(
'/:sitecode/:controller/:action/*',
array('controller' => :controller, 'action' => :action),
array('sitecode' => '[A-Z]{20}', pass => ['sitecode'])
);
Later in your code get sitecode using - $this->request->params['sitecode']