带有排序选项的代码点火器分页
我不确定我要问的是否可能。我想可能不会,但我想无论如何我都会问。
有什么办法可以重置分页吗?
我有一个页面,上面有分页和排序选项。一切正常,但是当其中一个排序选项更改时,我想将用户发送回第一页。
(我很确定我这样做的方式根本不是获得我想要的结果的最佳方式,所以如果您有任何改进建议,请随时提出。)
$array = explode ("_",$this->uri->segment(4));
if(count($array) > 1){
$search_id = $array[1];
$start = $this->uri->segment(5);
$uri_segment = 5;
}else{
$start = $this->uri->segment(4);
$uri_segment = 4;
$search_id = null;
}
$config['per_page'] = $this->settings['PRODUCTS_PER_PAGE'];
$config['total_rows'] = $this->categories_model->get_num_rows($cat_id , $search_type, $search_data);
$query = $this->categories_model->get_category_pages($cat_id, $new_limit, $new_sort, $search_id, $start, $this->settings['CATEGORY_ORDER'], $search_type, $search_data, $config['total_rows']))
$config['base_url'] = base_url() . 'index.php/categories/view/' . $cat_id ."/" . $search_string ;
$config['uri_segment'] = $uri_segment;
//Congig settings for pagination
$config['full_tag_open'] = '<div id="pagination" style= "clear:both;">';
$config['full_tag_close'] = '</div>';
//Initialise pagination
$this->pagination->initialize($config);
I'm not sure if what I'm about to ask is possible or not.. I'm thinking probably not but I thought I would ask anyways.
Is there any way to reset the pagination?
I've got a page with has pagination and sort option on it. Everything works fine but when one of the sort options is changed I would like to send the user back to the first page.
(I'm pretty sure the way I'm doing this isn't at all the best way to get the result I want so if you have any suggestions for improvements please feel free.)
$array = explode ("_",$this->uri->segment(4));
if(count($array) > 1){
$search_id = $array[1];
$start = $this->uri->segment(5);
$uri_segment = 5;
}else{
$start = $this->uri->segment(4);
$uri_segment = 4;
$search_id = null;
}
$config['per_page'] = $this->settings['PRODUCTS_PER_PAGE'];
$config['total_rows'] = $this->categories_model->get_num_rows($cat_id , $search_type, $search_data);
$query = $this->categories_model->get_category_pages($cat_id, $new_limit, $new_sort, $search_id, $start, $this->settings['CATEGORY_ORDER'], $search_type, $search_data, $config['total_rows']))
$config['base_url'] = base_url() . 'index.php/categories/view/' . $cat_id ."/" . $search_string ;
$config['uri_segment'] = $uri_segment;
//Congig settings for pagination
$config['full_tag_open'] = '<div id="pagination" style= "clear:both;">';
$config['full_tag_close'] = '</div>';
//Initialise pagination
$this->pagination->initialize($config);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在控制器中保留默认排序,该排序不会显示在 url 中。因此排序不会返回到第一页。
一个样本
you may keep a default sorting in controller which will not show in url.so sorting will not back to the first page.
a sample