1

Zend_Route 代码问题

此代码正在运行。

resources.router.routes.babynameslist.route               = "baby-names/baby-boy-names-list-from/:char
resources.router.routes.babynameslist.defaults.module     = "default"
resources.router.routes.babynameslist.defaults.controller = "index"
resources.router.routes.babynameslist.defaults.action     = "babynameslist"

http://example.com/baby-names/baby-boy-names-list-from/a/

但我想用这个。

resources.router.routes.babynameslist.route               = "baby-names/baby-boy-names-list-from-:char/"
resources.router.routes.babynameslist.defaults.module     = "default"
resources.router.routes.babynameslist.defaults.controller = "index"
resources.router.routes.babynameslist.defaults.action     = "babynameslist"

它不起作用( -:char/ )

http://example.com/baby-names/baby-boy-names-list-from-a/

请帮助我如何制作“baby-boy-names-list-from-a”

4

2 回答 2

0

您可以考虑使用Zend_Controller_Router_Route_Regex.
定义如下:

resources.router.routes.babynameslist.type                = "Zend_Controller_Router_Route_Regex"
resources.router.routes.babynameslist.route               = "baby-names/baby-boy-names-list-from-(\w)/"
resources.router.routes.babynameslist.map.1               = "char"
resources.router.routes.babynameslist.defaults.module     = "default"
resources.router.routes.babynameslist.defaults.controller = "index"
resources.router.routes.babynameslist.defaults.action     = "babynameslist"
于 2012-07-20T16:32:31.890 回答
0

我认为你应该将“a”传递给一个变量,并相应地调整你的脚本。我不确定,但我认为动态路由在 Zend_Route 中不起作用。

例如 :

http://example.com/baby-names/baby-boy-names-list-from/a
于 2012-07-20T12:36:57.563 回答