Welcome Guest, Not a member yet? Register   Sign In
Pagination best practices
#1

Hello everyone, i am wondering if someone could share a few best practises for doing pagination with the CI library.

Currently i do it like

PHP Code:
public function method() {
        
$config["base_url"] = base_url('controller/method/page');
        
$config["total_rows"] = $this->items_model->count();
        
$config["per_page"] = 20;
        
$config["uri_segment"] = 4;

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

        
$start = ($this->uri->segment(4)) ? ($this->uri->segment(4)-1)*$config['per_page'] : 0;
        
$data["results"] = $this->items_model->get($config["per_page"], $start);
        
$data["links"] = $this->pagination->create_links();

        
$this->load->view("example1"$data);
    } 

Which really sucks.

Any advise or examples are very welcome!

Thanks guys!
Reply


Messages In This Thread
Pagination best practices - by gastongr - 12-20-2015, 12:44 PM
RE: Pagination best practices - by arma7x - 12-20-2015, 02:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB