Zend框架不关心指定的Custom Route
我创建了一个路由器并添加到控制器中,如下所示
public function _initRouting() {
// Get Front Controller Instance
$front = Zend_Controller_Front::getInstance();
// Get Router
$router = $front -> getRouter();
$routePage = new Zend_Controller_Router_Route('/page/:action/:cat/:parent/:id', array(
'controller' => 'page',
'action' => 'list',
'cat' => 'general',
'parent' => '0',
'module' => 'default'
));
$router -> addRoute('page', $routePage);
}
首先,每当我导航到 /page/list/general/0/1
,它采用标准路线,而不是新路线。
I created a router and added to the controller like this
public function _initRouting() {
// Get Front Controller Instance
$front = Zend_Controller_Front::getInstance();
// Get Router
$router = $front -> getRouter();
$routePage = new Zend_Controller_Router_Route('/page/:action/:cat/:parent/:id', array(
'controller' => 'page',
'action' => 'list',
'cat' => 'general',
'parent' => '0',
'module' => 'default'
));
$router -> addRoute('page', $routePage);
}
First this router is not doing anything, whenever I navigation to/page/list/general/0/1
, it takes the standard route, not the new route.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我唯一能想到的是前端控制器资源在您的 init 方法之前尚未“引导”。
您至少应该引导并检索前端控制器资源
为什么不跳过创建引导初始化方法并在应用程序配置中配置路由器资源呢?
作为测试,我添加了上述配置并使用此
listAction
创建了一个PageController
调用
page/list/general/0/1
产生The only thing I can think of is the front controller resource has not been "bootstrapped" prior to your init method.
You should at least bootstrap and retrieve the front controller resource
Why don't you just skip creating a bootstrap init method and configure the router resource in your application config?
As a test, I added the above config and created a
PageController
with thislistAction
Calling
page/list/general/0/1
yields