我正在处理分页,并且我想从中修改分页网址: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);
}
你能帮我吗?
答案 0 :(得分:0)
如果可以生成这样的链接
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
详细说明