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
#2

My experience using free webhosting for demo and testing purpose. The server does not support mod_rewrite and cause all link with base_url() became error 404. Since the day, I use site_url() for pagination and only use base_url() to locate JavaScript, css and other assets in htdocs.
KeepĀ calm.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB