Zend_Router_Regex 和附加参数
我不知道如何实现它。
此路由器的
$route = new Zend_Controller_Router_Route_Regex(
'category/([-\w]+)(?:/(\d+))?',
array('module' => 'dynamic', 'controller' => 'index', 'action' => 'show-category'),
array(1 => 'category', 2 => 'pageNumber'),
'category/%s/%d'
);
$router->addRoute('dynamic-categories', $route);
我使用 $this->url(...) 帮助程序查看 组装 url 将是 /category/news/1 。我希望我的新闻首页是/category/news。我应该使用其他路由来执行此操作还是使用路由器链接。我很沮丧。谢谢你的帮助。
I have no idea how realize it.
I have this router
$route = new Zend_Controller_Router_Route_Regex(
'category/([-\w]+)(?:/(\d+))?',
array('module' => 'dynamic', 'controller' => 'index', 'action' => 'show-category'),
array(1 => 'category', 2 => 'pageNumber'),
'category/%s/%d'
);
$router->addRoute('dynamic-categories', $route);
Assembled url in view will be /category/news/1 by using $this->url(...) helper. I want that my first page of news will be /category/news. Should I use other route to do it or use router chaining. I'm frustrated. Thank you for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
Zend_Controller_Router_Route
进行直接映射:将匹配
/category/
、/category/news/
、/category/othercategory< /code> 或
/category/news/4
(当然仅作为示例)。You can use
Zend_Controller_Router_Route
for straight forward mapping:Will match
/category/
,/category/news/
,/category/othercategory
or/category/news/4
(examples only of course).