0
votes

I am working on pagination and I want to modify my pagination url from this: http://localhost/Pedestana/index.php/Pengunjung/index/#desa/ (this is pagination offset) to this: http://localhost/Pedestana/index.php/Pengunjung/index/ (this is pagination offset)/#desa. and when the page is loaded, it will scroll down to id #desa

I have tried change the config['uri_segment'], but it doesn't work properly.

public function index(){
    $this->load->database();
    $jumlah_data = $this->model_desa->jumlah_data();
    $this->load->library('pagination');
    $config['base_url'] =base_url().'index.php/Pengunjung/index/offset/#desa';
    $config['total_rows'] = $jumlah_data;
    $config['per_page'] = 10;
    $from = $this->uri->segment(3); 
    $config['uri_segment']='offset';
    $this->pagination->initialize($config);
    $data['kecamatan']=$this->model_kecamatan->kecamatan();
    $data['desa']=$this->model_desa- >data($config['per_page'],$from);
    $this->load->view('Pengunjung/index',$data);
}

Can you help me please?

1

1 Answers

0
votes

if its okay to generate link like this

http://localhost/Pedestana/Pengunjung/index/#desa?per_page=20

Then you can set:

$config['enable_query_strings'] set to TRUE 

And use Get method in place of:

$from = $this->uri->segment(3); //replace this with get method to get per_page data

i.e

$this->input->get('per_page');  //Get method to get per_page

You can see the link https://www.codeigniter.com/user_guide/libraries/pagination.html

for its elaborated usage