晦涩de咚
求优化URL:http://localhost:92/frontend/web/posts/index.html?page=3&per-page=10 ,能优化成http://localhost:92/frontend/web/posts/index/page/3.html
@xiaoshenzhen 我写了解决方案,谢谢啦,已解决自己解答下吧:
期初规则写的不够明确,导致URL没效果;
后来经过小kk提示说书写明确的规则'suffix'=>'.html', 'rules' => [ "posts/index/<page:\d+>" => "posts/index", //可以 // "<controller:[-\w]+>/<action:[-\w]+>/<page:\d+>" => "<controller>/<action>", //不可以,与id冲突 "<controller:[-\w]+>/<action:[-\w]+>/<id:\d+>/<page:\d+>" => "<controller>/<action>", "<module:[-\w]+>/<controller:[-\w]+>/<action:[-\w]+>/<id:\d+>" => "<module>/<controller>/<action>", "<controller:[-\w]+>/<action:[-\w]+>/<id:\d+>" => "<controller>/<action>", "<controller:[-\w]+>/<action:[-\w]+>" => "<controller>/<action>", ],
此时出现了
http://localhost:92/frontend/web/posts/index/3.html?per-page=10
感觉还没满足自己,于是再去看下自己设置的每页显示数对比源码发现
$pages = new Pagination(['totalCount' => $countQuery->count(),'PageSize' => '10']);//修改前 //修改为下面 $pages = new Pagination(['totalCount' => $countQuery->count(),'defaultPageSize' => '10']);//修改后
- 晦涩de咚 回答了问题 TimestampBehavior小问题
其实时间一定会被填充的,只不过不需要在rule规则中出现;一旦你时间字段出现在rule的必填规则,那么他会在你进行插入的时候load验证的,然而TimestampBehavior是在验证之后产生的,所以不需要。
- 晦涩de咚 2016-08-09 已签到连续签到39天,获得了20个金钱
- 晦涩de咚 发表了说说求优化URL:http://localhost:92/frontend/web/posts/index.html?page=3&per-page=10 ,能优化成http://localhost:92/frontend/web/posts/index/page/3.html