我是每个正在读这篇文章的人,
我5分钟前在网上找到了一个非常好的网址:
www.exemple.com/blog/rating.asc/2
与:
有关blog => controller/action/module or anything
rating => ordered by
asc => order of list
2 => current page
我想知道如何使用Zend Framework的Zend_Controller_Router_Route
类创建类似的URL。
对于我的网站,它会像:
www.exemple.com/portfolio/date.asc/2
或
www.exemple.com/blog/author.desc/ (page optional, default 1)
和
www.exemple.com/blog/ (default order: date.asc, page: 1)
注意:我对Regex并不友好,所以我想禁止那个,或者如果有人表达了确切的话,我们将不胜感激。
答案 0 :(得分:1)
嘿,我不确定你是否使用ini进行配置,但如果我有以下内容,我就会这样做:
module => blog
controller => article
action => list
// Parameter to get from the request in the controller
// Note that those are the defaults in case you don't provide any parameters in the url
sortBy => author
order => asc
page => 1
ini文件中的:
; /www.exemple.com/blog/articles/author/desc/2
resources.router.routes.whateverroutname.route = /blog/articles/:sortBy/:order/:page
resources.router.routes.whateverroutname.defaults.module = blog
resources.router.routes.whateverroutname.defaults.controller = article
resources.router.routes.whateverroutname.defaults.action = list
resources.router.routes.whateverroutname.defaults.sortBy = author
resources.router.routes.whateverroutname.defaults.order = asc
resources.router.routes.whateverroutname.defaults.page = 1
希望这会有所帮助:)