0
我想写路线对于这种类型的网址Zend框架2动态路由
http://www.example.com/category/sub-category/id.html
这里类别是动态的。意味着我的数据库中有100个类别。子类别 也是动态的。 我需要根据id值显示页面。 任何人都请建议。
我想写路线对于这种类型的网址Zend框架2动态路由
http://www.example.com/category/sub-category/id.html
这里类别是动态的。意味着我的数据库中有100个类别。子类别 也是动态的。 我需要根据id值显示页面。 任何人都请建议。
尝试读取文档首很简单:
'sample' => array(
'type' => 'Segment',
'options' => array(
'route' => '/:category[/:sub_category[/:id]].html',
'defaults' => array(
'controller' => 'Your Controller',
'action' => 'Your Action',
),
),
),
有了这个路由器的配置,你可以有:
http://www.example.com/category.html
http://www.example.com/category/sub-category.html
http://www.example.com/category/sub-category/id.html
谢谢@ Xlord27。你的答案是有帮助的 – 2013-05-27 12:16:28
我建议先阅读[ZF2Docs:路由和控制器(HTTP:/ /zf2.readthedocs.org/en/latest/user-guide/routing-and-controllers.html),然后获取更多详细信息[ZF2Docs:Zend Mvc路由](http://zf2.readthedocs.org/en/latest/模块/ zend.mvc.routing.html)。然后你回来了,你已经尝试过,我们会帮你;) – Sam 2013-05-10 06:26:28
对于这种事情,我会试图扩展一个可用的路由器来做一个自定义路由器来检查你的数据库/使用缓存 – Andrew 2013-05-10 08:00:23