CakePHP自定义路由分页

CakePHP自定义路由分页,cakephp,pagination,Cakephp,Pagination,我想将我的URL格式化为: /news/index/page:2 到 /news/2 我希望在不修改PaginatorHelper行为的情况下,通过使用尽可能少的代码(可能仅来自routes.php?)来实现这一结果 谢谢你的帮助 这应该行得通 // Add this to /app/config/routes.php Router::connect('/news/:page', array('controller' => 'news', 'action' => 'index'));

我想将我的URL格式化为:

/news/index/page:2

/news/2

我希望在不修改PaginatorHelper行为的情况下,通过使用尽可能少的代码(可能仅来自routes.php?)来实现这一结果

谢谢你的帮助

这应该行得通

// Add this to /app/config/routes.php
Router::connect('/news/:page', array('controller' => 'news', 'action' => 'index'));

工作起来很有魅力!非常感谢。不过,还有一件事……我想显示
news
而不是
news/1
,所以我不会有两个URL指向同一个页面……如何从
router.php
执行此操作?而且,
:page
是默认路由元素还是自定义路由元素?如果它是自定义的,为什么不需要在
Router::connect()
方法的第三个参数中“解释”呢?
:page
是命名属性,由
Pagination
类自动解析,这个类查找
$This->params[page]
,无论您如何传递它。这对你来说可能很有趣。。。干杯谢谢你的澄清。关于
news/1
news
问题,你有什么想法吗?再次感谢。没有控制此参数的配置。如果你真的想这么做,你必须破解分页助手。建议的解决方案是将此页面链接到
(默认页面值为1),并让分页器在人们浏览页面时附加数字。