Kohana 3 分页
我真的不知道 Kohana 3 中的分页是如何工作的。Kohana 3 中是否有一个很好的分页示例?
I'm really lost on how pagination works in kohana 3. Is there a good example of pagination in Kohana 3 anywhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
然后在视图中,您只需执行
这里发生的事情是 Pagination 类,使用它的 View 的 __toString() 魔术方法来渲染显示分页所需的 html。创建对象时可以修改所有分页参数(在我们的例子中将适当的键传递给传递给factory()方法的数组)。
分页的默认键是“page”(查询字符串),您也可以修改它。分页还有一个默认配置,您可以通过将其复制到 application/config 文件夹来覆盖它。
享受使用它的乐趣:)
and then in the View, you just do
What happens here is Pagination class using it's View's __toString() magic method to render html needed to display pagination. All pagination params can be modified when creating the object (passing appropriate keys to the array passed to factory() method in our case).
Default key for pagination is "page" (query string), while you can modify that as well. Pagination also has a default config, which you can override by copying it to application/config folder.
Enjoy using it :)
Kohana 3.1 中不包括分页。下载模块并将其放入modules文件夹中。在 application/bootstrap.php 中启用该模块。这是我的控制器页面。如需进一步配置,请将提供的配置文件从 modules/pagination/config/pagination.php 复制到 application/config/pagination.php
您可能会收到错误 ErrorException [Notice]: Undefined属性:
Request::$uri
。在分页类(模块)中。为了修复它,请使用
Request::current()->uri()
而不是Request::current()->uri
In Kohana 3.1 pagination is not included. Download the module and put it in the modules folder. Enable the module in your application/bootstrap.php .This is my controller page. For further configuration copy the provided config file from modules/pagination/config/pagination.php to application/config/pagination.php
You may get error ErrorException [ Notice ]: Undefined property:
Request::$uri
. in the pagination class (module). In order to fix fix itUse
Request::current()->uri()
instead ofRequest::current()->uri
您可以在非官方 Kohana wiki 中找到一些不错的文档。
You can find some decent docs in the unofficial Kohana wiki.