【发布时间】:2015-06-04 12:28:15
【问题描述】:
我使用的是 CakePHP 1.3 并且在前缀路由方面遇到了一些问题。
我这样配置路由:
Router::connect(
'/listing/*',
array(
'controller' => 'dsc_dates',
'action' => 'listing',
)
);
Router::connect(
'/modular/listing/*',
array(
'controller' => 'dsc_dates',
'action' => 'listing',
'prefix' => 'modular'
)
);
在我的控制器中有两个功能:
function modular_listing($order = null,$orderDirection = null, $items=null, $location_id=null) {
$this->layout='module';
$this->setAction('listing',$order, $orderDirection, $items, $location_id);
}
function listing($order = null,$orderDirection = null, $items=null, $location_id=null){...}
前缀动作应该只是改变一些东西,然后像正常的“列表”方法一样操作。直到这里它工作正常。
但如果我创建相对链接(使用 HTML Helper)Router::url() 使用 'modular_listing' 作为不适合我的路由的操作。它应该是“listing”而不是“modular_listing”。 控制器参数在“listing”作为操作时是正确的,但路由器参数仍然显示“modular_listing”。
所以相对链接:
$this->Html->link('example',array('parameter'));
最终会在:
/dsc_dates/modular_listing/parameter
如何获得正确的链接,以便路由器使用“列表”作为操作?
更新: 在链接生成的 url 数组中添加“控制器”和“动作”不是替代方法。事实上,我对分页器自动生成的相对链接有问题。
【问题讨论】:
标签: php cakephp cakephp-1.3