我有一个带有路由的博客。在我的ini中,它看起来是这样的:
routes.quote.route = :id
routes.quote.defaults.module = default
routes.quote.defaults.controller = posts
routes.quote.defaults.action = single
routes.quote.reqs.id = 'd+
现在我想要一个额外的页面参数(用于注释)。我只是通过创建这样一个扇形路线得到的:
routes.quotePage.route = :id/page/:page
routes.quotePage.defaults.module = default
routes.quotePage.defaults.controller = posts
routes.quotePage.defaults.action = single
routes.quotePage.reqs.id = 'd+
routes.quotePage.reqs.page = 'd+
我想把这两者合二为一。我该怎么做?page参数应该只是附加的。
谢谢
像这样使用Zend_Controller_Router_Route_Regex:
routes.quote.route.type = "Zend_Controller_Router_Route_Regex"
routes.quote.route = posts/('d+)/('d+)
routes.quote.defaults.module = default
routes.quote.defaults.controller = posts
routes.quote.defaults.action = single
routes.quote.map.1 = "id"
routes.quote.map.1 = "page"
您可以为页面参数分配一个默认值
routes.quotePage.route = :id/:page
routes.quotePage.defaults.module = default
routes.quotePage.defaults.controller = posts
routes.quotePage.defaults.action = single
routes.quotePage.defaults.page = 1
routes.quotePage.reqs.id = 'd+
routes.quotePage.reqs.page = 'd+
这将与http://domain.com/1
和http://domain.com/1/page/1
或http://domain.com/1/page/2
匹配