Welcome Guest, Not a member yet? Register   Sign In
Pagination Fatal Error
#1

[eluser]Flipside Tech[/eluser]
Trying to use the pagination class for the first time and I received a PHP error.

Fatal error: Call to a member function segment() on a non-object in /webroot/_codeigniter/libraries/Pagination.php on line 136

Code:
Code:
$this->load->library('pagination');    

$this->pagination->initialize(array(
    'base_url' => base_url().'featured',
    'uri_segment' => 2,
    'total_rows' => (int)$this->caption_model->getTotalCount(),
    'per_page' => RECORDS_PER_PAGE
    ));

print_r(array(
    'base_url' => base_url().'featured',
    'uri_segment' => 2,
    'total_rows' => (int)$this->caption_model->getTotalCount(),
    'per_page' => RECORDS_PER_PAGE
    ));

echo $this->pagination->create_links();


Output:

Code:
Array (
    [base_url] => http://www.domain.com/featured
    [uri_segment] => 2
    [total_rows] => 19
    [per_page] => 15
)
Fatal error: Call to a member function segment() on a non-object in /webroot/_codeigniter/libraries/Pagination.php on line 135


What up? Any ideas?
#2

[eluser]Flipside Tech[/eluser]
Line 135 is:
Code:
if ($CI->uri->segment($this->uri_segment) != 0)

I dumped $CI->uri and it was NULL.
#3

[eluser]Flipside Tech[/eluser]
I found some weirdness. It appears pagination works fine if I load it and display the links before I load any models. Once I make a call to $this->load->model, pagination is broken. It appears that after loading models the $CI->uri data is gone.

Anyone else experiencing similar issues?

Ryan




Theme © iAndrew 2016 - Forum software by © MyBB