0

I have this code in my module

$this->EE->load->library('pagination');
$pagination = $this->EE->pagination->create(__CLASS__);
...

The problem is that I get this error

Fatal error: Call to undefined method EE_Pagination::create() in ...

I am using EE 2.5.5

Is there some changes that make this code not work? Is there a new way to do this?

1

create() method in pagination library was only added in EE 2.6

In one of my modules, I use this code:

if ($this->EE->config->item('app_version') >= 260)
{
$pagination = $this->EE->pagination->create(__CLASS__);
}
else
{
$pagination = new Pagination_object(__CLASS__);
}
0

There is no create method, there's create_links or render.

Two methods I use:

//###   Prep the Pagination   ###
$this->EE->load->library('pagination');
$pagination = new Pagination_object(__CLASS__);
//###   Set any settings   ###
$pagination->dynamic_sql = TRUE;
$pagination->basepath = $this->EE->functions->create_url($this->EE->uri->uri_string);
$pagination->per_page  = ( !is_numeric($this->EE->TMPL->fetch_param('limit')) )  ? $defaultLimit : $this->EE->TMPL->fetch_param('limit');
$pagination->build($total, $primarySQL);
$tagdata = $pagination->render($tagdata);

...or:

    $this->EE->load->library('pagination');
    $config['base_url'] = $base_url;
    $config['total_rows'] = $total;
    $config['per_page'] = $per_page;
    $config['num_links'] = 3;
    $config['uri_segment'] = 4;
    $config['first_link'] = '1';
    $config['first_tag_open'] = '<div class="pag-first">';
    $config['first_tag_close'] = '</div>';
    $config['next_tag_open'] = '';
    $config['next_tag_close'] = '';
    $config['num_tag_open'] = '';
    $config['cur_tag_open'] = '<strong>';
    $config['prev_tag_open'] = '';
    $config['last_link'] = ceil($total/$per_page);
    $config['last_tag_open'] = '<div class="pag-last">';
    $config['last_tag_close'] = '</div>';

    $this->EE->pagination->initialize($config);

    return $this->EE->pagination->create_links();

References:

http://ellislab.com/expressionengine/user-guide/development/module_tutorial.html http://ellislab.com/codeigniter/user-guide/libraries/pagination.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.