【问题标题】:How to modify pagination base_url in codeigniter如何在codeigniter中修改分页base_url
【发布时间】:2019-06-12 16:50:28
【问题描述】:

我正在处理分页,我想修改我的分页网址: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);
}

你能帮帮我吗?

【问题讨论】:

    标签: php codeigniter codeigniter-3


    【解决方案1】:

    如果可以生成这样的链接

    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

    因为它的详细用法

    【讨论】:

    • 它可以工作,但页面不会向下滚动到 id #desa
    猜你喜欢
    • 1970-01-01
    • 2018-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-20
    • 2013-12-03
    相关资源
    最近更新 更多