Reputation: 297
I am trying to user the Codeigniter pagination and I receive the following error "Fatal error: Call to undefined method Pagination::initialize()".
I found a few post with the same issue but they all stated the solution is to auto load the Pagination class which I am already doing. The only issue I can think of is that my class uses custom controller "MY_Controller" which extends the CI controller. Below is my code, please help. Thanks in advance.
MY_Controller.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Controller extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->init();
}
}
Main Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends MY_Controller {
function index()
{
$this->display();
}
function display()
{
//pagination settings
$config['base_url'] = base_url();
$config['total_rows'] = 200;
$config['per_page'] = 50;
$this->pagination->initialize($config);
}
}
Upvotes: 1
Views: 2559
Reputation: 16117
If you made a custom controller and extend it with core My_Controller
than load pagination library inside the display()
function:
$this->load->library('pagination');
Upvotes: 1