我想在CI_pagination
类中添加ajax分页,但为此我想创建一个扩展CI_Pagination类的类MY_Pagination
但是当我{{1}使用此库时它会出错在我的控制器中:
并在新的MY_Pagination类中调用测试函数
$this->load->library('pagination');
我还在config.php中添加了行Fatal error: Call to undefined method CI_Pagination::test() ...
由于http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html
$config['subclass_prefix'] = 'MY_';
,我更改了子类名称
这是我的代码
Please note that all native CodeIgniter libraries are prefixed with CI_ so DO NOT use that as your prefix.
此代码保存在文件MY_Pagination.php。
中我从https://www.codeigniter.com/user_guide/general/creating_libraries.html阅读了该文件,但这不起作用?
答案 0 :(得分:1)
在尝试扩展之前加载CI_Pagination
类,所以
$this->load->library('pagination'); // base class
$this->load->library('ajax_pagination'); // custom derived class
答案 1 :(得分:0)
为什么要为分页构建一个库。
Codeigniter已经有一个分页库
参考此
http://ellislab.com/codeigniter/user-guide/libraries/pagination.html