Php 创建分页、排序和筛选器的URL-ZF

Php 创建分页、排序和筛选器的URL-ZF,php,zend-framework,url,url-rewriting,zend-router,Php,Zend Framework,Url,Url Rewriting,Zend Router,我相信每一个读到这篇文章的人 我5分钟前上网,发现了一个相当不错的URL: 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\u Controller\u Router\u Rou

我相信每一个读到这篇文章的人

我5分钟前上网,发现了一个相当不错的URL:

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\u Controller\u Router\u Route
类创建类似的URL

对于我的网站,它将类似于:

www.exemple.com/portfolio/date.asc/2


注意:我对Regex不友好,所以我想禁止这样做,或者如果有人知道确切的表达式,我将不胜感激。

嘿,我不确定您是否使用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

希望这有帮助:)

嘿,我不确定您是否使用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

希望这有帮助:)

嗯,这很好,只是排序和顺序不是由
/
划分的,而是由
划分的。Zend路由器根据路由匹配来分离参数。匹配的参数分隔符为“/”。也许你必须编写你自己的作者,将它作为“参数分隔符”和“类似于这个/博客/文章/:SotBube的秘密路由”。请记住,“.”符号有时用于分隔CEO中的单词。因此,您的链接可能会被一些搜索引擎误解。好吧,这很好,只是排序和顺序不是由
/
划分的,而是由
划分的。Zend路由器根据路由匹配来分离参数。匹配的参数分隔符为“/”。也许你必须编写你自己的作者,将它作为“参数分隔符”和“类似于这个/博客/文章/:SotBube的秘密路由”。请记住,“.”符号有时用于分隔CEO中的单词。因此,你的链接可能会被一些搜索引擎误解。