我正在尝试更好地查看我的动态分页,但它不起作用

我有产品的动态分页。我的分页工作正常,只是我想更好地查看我的分页。


看法:


 <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'] = '&nbsp;<a class="page-link">';

            $config['cur_tag_close'] = '</a>';

            $config['next_link'] = 'Next';

            $config['prev_link'] = 'Previous';


我想显示分页看起来像下图。

http://img3.mukewang.com/62a3effd00019bae03020052.jpg

$config为分页设置了所有必要的配置。我不知道我的代码哪里错了



阿晨1998
浏览 153回答 2
2回答

繁花如伊

您做得很好,但没有在自定义分页中添加 html 标签。只需在当前代码之间添加一些行。function category($rowno=0)&nbsp; &nbsp; &nbsp; &nbsp;{&nbsp; &nbsp; &nbsp; &nbsp; $rootCatId&nbsp; =&nbsp; &nbsp;$this->input->get('rootCatId');&nbsp; &nbsp; &nbsp; &nbsp; $subCatId&nbsp; &nbsp;=&nbsp; &nbsp;$this->input->get('subCatId');&nbsp; &nbsp; &nbsp; &nbsp; $rowno&nbsp; &nbsp; &nbsp; =&nbsp; &nbsp;$this->input->get('per_page');&nbsp; &nbsp; &nbsp; &nbsp; $data=array();&nbsp; &nbsp; &nbsp; &nbsp; if($rootCatId > 0 && $subCatId== 0){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rowperpage = 12;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($rowno != 0){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rowno = ($rowno-1) * $rowperpage;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $search_text = "";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($this->input->post('submit') != NULL ){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $search_text = $this->input->post('search');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this->session->set_userdata(array("search"=>$search_text));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($this->session->userdata('search_product') != NULL){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $search_text = $this->session->userdata('search_product');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rowperpage = 12;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($rowno != 0){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rowno = ($rowno-1) * $rowperpage;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $allcount = $this->product->getrecordCount($search_text);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $users_record = $this->product->fetchAllProductByMainCat($rootCatId,$rowno,$rowperpage,$search_text);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['base_url']&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= base_url().'category';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['uri_segment']&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 3;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['reuse_query_string']&nbsp; &nbsp;= TRUE;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['enable_query_strings'] = TRUE;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['page_query_string']&nbsp; &nbsp; = TRUE;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['use_page_numbers']&nbsp; &nbsp; &nbsp;= TRUE;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['total_rows']&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= $allcount;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['per_page']&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= $rowperpage;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['cur_tag_open'] = '&nbsp;<a class="page-link">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['cur_tag_close'] = '</a>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['next_link'] = 'Next';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['prev_link'] = 'Previous';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //This segment is used for the design (looks) start here&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['full_tag_open'] = '<ul class="pagination">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['full_tag_close'] = '</ul>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['num_tag_open'] = '<li class="page-item">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['num_tag_close'] = '</li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['cur_tag_close'] = '</a></li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['next_tag_open'] = '<li class="page-item">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['next_tagl_close'] = '</a></li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['prev_tag_open'] = '<li class="page-item">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['prev_tagl_close'] = '</li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['first_tag_open'] = '<li class="page-item disabled">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['first_tagl_close'] = '</li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['last_tag_open'] = '<li class="page-item">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['last_tagl_close'] = '</a></li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['attributes'] = array('class' => 'page-link');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this->pagination->initialize($config);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//This segment is used for the design (looks) end here&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Initialize&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this->pagination->initialize($config);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['pagination'] = $this->pagination->create_links();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['viewAll']&nbsp; &nbsp; = $users_record;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['row']&nbsp; &nbsp; &nbsp; &nbsp; = $rowno;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['search']&nbsp; &nbsp; &nbsp;= $search_text;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}elseif($rootCatId > 0 && $subCatId !==0 && $subCatId > 0){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rowperpage = 12;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($rowno != 0){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $rowno = ($rowno-1) * $rowperpage;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $search_text = "";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($this->input->post('submit') != NULL ){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $search_text = $this->input->post('search');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this->session->set_userdata(array("search"=>$search_text));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($this->session->userdata('search_product') != NULL){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $search_text = $this->session->userdata('search_product');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $allcount = $this->product->getrecordCount($search_text);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $users_record = $this->product->fetchProductByCat($rootCatId,$subCatId,$rowno,$rowperpage,$search_text);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['base_url'] = base_url().'category';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['reuse_query_string'] = TRUE;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['enable_query_strings']=TRUE;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['page_query_string'] = TRUE;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['use_page_numbers'] = TRUE;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['total_rows'] = $allcount;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['per_page'] = $rowperpage;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['cur_tag_open'] = '&nbsp;<a class="page-link">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['cur_tag_close'] = '</a>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['next_link'] = 'Next';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['prev_link'] = 'Previous';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //This segment is used for the design (looks) start here&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['full_tag_open'] = '<ul class="pagination">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['full_tag_close'] = '</ul>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['num_tag_open'] = '<li class="page-item">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['num_tag_close'] = '</li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['cur_tag_close'] = '</a></li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['next_tag_open'] = '<li class="page-item">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['next_tagl_close'] = '</a></li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['prev_tag_open'] = '<li class="page-item">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['prev_tagl_close'] = '</li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['first_tag_open'] = '<li class="page-item disabled">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['first_tagl_close'] = '</li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['last_tag_open'] = '<li class="page-item">';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['last_tagl_close'] = '</a></li>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $config['attributes'] = array('class' => 'page-link');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this->pagination->initialize($config);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//This segment is used for the design (looks) end here&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['pagination'] = $this->pagination->create_links();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['viewAll'] = $users_record;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['row'] = $rowno;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['search'] = $search_text;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['get_website_content'] = $this->pg_model->get_website_content();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['BannerImage']&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= $this->product->fetchBannerImage($rootCatId);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['MainName']&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = $this->product->NameByMainCat($rootCatId);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['SubName']&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= $this->product->NameBySubCat($subCatId);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['product_list_commercial']&nbsp; &nbsp; = $this->pg_model->product_list_commercial();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this->load->view('template/header',$data);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this->load->view('category');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this->load->view('template/footer');&nbsp; &nbsp; }在此之后,您可以根据添加的类属性添加自定义 css,包括在 html 上。

慕标琳琳

如果您使用的是引导程序,那么您可以将以下代码与其他配置值一起使用,/* Pagination buttion style start&nbsp; */&nbsp; &nbsp; $config['full_tag_open'] = "<ul class='pagination'>";&nbsp; &nbsp; $config['full_tag_close'] = '</ul>';&nbsp; &nbsp; $config['num_tag_open'] = '<li>';&nbsp; &nbsp; $config['num_tag_close'] = '</li>';&nbsp; &nbsp; $config['cur_tag_open'] = '<li class="active"><a href="#">';&nbsp; &nbsp; $config['cur_tag_close'] = '</a></li>';&nbsp; &nbsp; $config['prev_tag_open'] = '<li>';&nbsp; &nbsp; $config['prev_tag_close'] = '</li>';&nbsp; &nbsp; $config['first_tag_open'] = '<li>';&nbsp; &nbsp; $config['first_tag_close'] = '</li>';&nbsp; &nbsp; $config['last_tag_open'] = '<li>';&nbsp; &nbsp; $config['last_tag_close'] = '</li>';&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; $config['prev_link'] = '<i class="fa fa-chevron-left"></i>';&nbsp; &nbsp; $config['prev_tag_open'] = '<li>';&nbsp; &nbsp; $config['prev_tag_close'] = '</li>';&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; $config['next_link'] = '<i class="fa fa-chevron-right"></i>';&nbsp; &nbsp; $config['next_tag_open'] = '<li>';&nbsp; &nbsp; $config['next_tag_close'] = '</li>';&nbsp; &nbsp; /* Pagination buttion style end */
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript