【发布时间】:2020-03-28 23:24:09
【问题描述】:
我有产品的动态分页。我的分页工作正常,只是我想更好地查看我的分页。
查看:
<div style='margin-top: 10px;' class="page-link" align="center">
<?= $pagination; ?>
</div>
控制器:
function category($rowno=0)
{
$rootCatId = $this->input->get('rootCatId');
$subCatId = $this->input->get('subCatId');
$rowno = $this->input->get('per_page');
$data=array();
if($rootCatId > 0 && $subCatId== 0){
$rowperpage = 12;
if($rowno != 0){
$rowno = ($rowno-1) * $rowperpage;
}
$search_text = "";
if($this->input->post('submit') != NULL ){
$search_text = $this->input->post('search');
$this->session->set_userdata(array("search"=>$search_text));
}else{
if($this->session->userdata('search_product') != NULL){
$search_text = $this->session->userdata('search_product');
}
}
$rowperpage = 12;
if($rowno != 0){
$rowno = ($rowno-1) * $rowperpage;
}
$allcount = $this->product->getrecordCount($search_text);
$users_record = $this->product->fetchAllProductByMainCat($rootCatId,$rowno,$rowperpage,$search_text);
$config['base_url'] = base_url().'category';
$config['uri_segment'] = 3;
$config['reuse_query_string'] = TRUE;
$config['enable_query_strings'] = TRUE;
$config['page_query_string'] = TRUE;
$config['use_page_numbers'] = TRUE;
$config['total_rows'] = $allcount;
$config['per_page'] = $rowperpage;
$config['cur_tag_open'] = ' <a class="page-link">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
// Initialize
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['viewAll'] = $users_record;
$data['row'] = $rowno;
$data['search'] = $search_text;
}elseif($rootCatId > 0 && $subCatId !==0 && $subCatId > 0){
$rowperpage = 12;
if($rowno != 0){
$rowno = ($rowno-1) * $rowperpage;
}
$search_text = "";
if($this->input->post('submit') != NULL ){
$search_text = $this->input->post('search');
$this->session->set_userdata(array("search"=>$search_text));
}else{
if($this->session->userdata('search_product') != NULL){
$search_text = $this->session->userdata('search_product');
}
}
$allcount = $this->product->getrecordCount($search_text);
$users_record = $this->product->fetchProductByCat($rootCatId,$subCatId,$rowno,$rowperpage,$search_text);
$config['base_url'] = base_url().'category';
$config['reuse_query_string'] = TRUE;
$config['enable_query_strings']=TRUE;
$config['page_query_string'] = TRUE;
$config['use_page_numbers'] = TRUE;
$config['total_rows'] = $allcount;
$config['per_page'] = $rowperpage;
$config['cur_tag_open'] = ' <a class="page-link">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['viewAll'] = $users_record;
$data['row'] = $rowno;
$data['search'] = $search_text;
}
$data['get_website_content'] = $this->pg_model->get_website_content();
$data['BannerImage'] = $this->product->fetchBannerImage($rootCatId);
$data['MainName'] = $this->product->NameByMainCat($rootCatId);
$data['SubName'] = $this->product->NameBySubCat($subCatId);
$data['product_list_commercial'] = $this->pg_model->product_list_commercial();
$this->load->view('template/header',$data);
$this->load->view('category');
$this->load->view('template/footer');
}
我想显示如下图的分页。
使用$config,我为分页设置了所有必要的配置。我不知道我的代码哪里错了
【问题讨论】:
-
现在是时候学习如何提出问题了……“我不知道我的代码哪里错了” - 如何我们应该知道吗?你没有向我们展示它目前的样子,你没有以任何方式描述你认为目前关于结果的“错误”......
标签: javascript php html twitter-bootstrap codeigniter