簡體   English   中英

如何在codeigniter中修改分頁base_url

[英]How to modify pagination base_url in codeigniter

我正在進行分頁,我想修改我的分頁URL: http://localhost/Pedestana/index.php/Pengunjung/index/#desa/ (這是分頁偏移)到這個: http:// localhost / Pedestana / index.php / Pengunjung / index / (這是分頁偏移)/ #desa。 當頁面加載時,它將向下滾動到id #desa

我已經嘗試更改config['uri_segment'] ,但它無法正常工作。

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);
}

你能幫我嗎?

如果可以生成這樣的鏈接

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

然后你可以設置:

$config['enable_query_strings'] set to TRUE 

並使用Get方法代替:

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

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

您可以看到鏈接https://www.codeigniter.com/user_guide/libraries/pagination.html

因其詳細的用法

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM