我的codeigniter分页无法将显示更改为下一个数据

时间:2015-02-02 23:55:29

标签: php twitter-bootstrap codeigniter pagination

我在stackoverflow上的新功能,当我点击' 2'时,我的分页不会更改为下一个数据。或者' next' ,我的分页功能不是索引,我使用twitter boostrap进行设计是否会产生任何影响?希望你们能解决我的错误英语问题,问候:)

这里是pagination.php(config / pagination.php)

$config['num_links'] = 2;
$config['page_query_string'] = TRUE;
// $config['use_page_numbers’] = TRUE;
$config['query_string_segment'] = 'catalog_page';

$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul><!–pagination–>';

$config['first_link'] = '&laquo; First';
$config['first_tag_open'] = '<li class="prev page">';
$config['first_tag_close'] = '</li>';

$config['last_link'] = 'Last &raquo;';
$config['last_tag_open'] = '<li class="next page">';
$config['last_tag_close'] = '</li>';

$config['next_link'] = '&rarr;';
$config['next_tag_open'] = '<li class="next page">';
$config['next_tag_close'] = '</li>';

$config['prev_link'] = '&larr;';
$config['prev_tag_open'] = '<li class="prev page">';
$config['prev_tag_close'] = '</li>';

$config['cur_tag_open'] = '<li class="active"><a href="">';
$config['cur_tag_close'] = '</a></li>';

$config['num_tag_open'] = '<li class="page">';
$config['num_tag_close'] = '</li>';

// $config['display_pages’] = FALSE;
//
$config['anchor_class'] = 'follow_link';

这是在控制器中管理我的分页的函数(controller / ui_controller.php)

public function to_category(){
        if(!empty($_GET['pid']) && !empty($_GET['nm_p'])){
            $id = 0 ;
            $data['pid'] = $_GET['pid'];
            $data['nm_p'] = $_GET['nm_p'];
            $data['gsi'] = $this->get_all_island_where_gs();
            $data['lsi'] = $this->get_all_island_where_ls();

            // load data
            $jml = $this->db->get('kategori_wisata');

            // generate pagination
            $config['base_url'] = base_url().'index.php/ui_controller/to_category?pid='.$data['pid'].'&&nm_p='.$data['nm_p'];
            $config['total_rows'] = $jml->num_rows();
            $config['per_page'] = 4;
            $config['uri_segment'] = 3 ;
            $this->pagination->initialize($config);

            $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
            $offset = $page==0? 0: ($page-1)*$config["per_page"];

            $data['category'] = $this->ui_model->get_all_category($config['per_page'] ,  $page);        

            $data['pagination'] = $this->pagination->create_links();

            $this->load->view('user/header.html' , $data);
            $this->load->view('user/category.html');
            $this->load->view('user/footer.html');
        }
    }

这是我的视图category.php(view / category.php)

<div class="row">
<div class="col-md-10 col-md-offset-1 col-xs-10 col-xs-offset-1 col-lg-10 col-lg-offset-1 col-sm-10 col-sm-offset-1 pilih-kategori col-shadow">
    <center><h1>Choose your category</h1></center>
    <?php
        foreach($category as $data) :
            $kwid = $data["kwid"];
            $nama_kategori = $data["nama"];
    ?>
            <div class="col-md-3 category">
                <a href="<?php echo base_url(); ?>index.php/ui_controller/pick_category?pid=<?php echo $pid; ?>&&nm_p=<?php echo $nm_p; ?>&&kwid=<?php echo $kwid; ?>&&nm_kw=<?php echo $nama_kategori; ?>">
                    <img class="tool-tip" data-toggle="tooltip" data-placement="top" title="<?php echo $nama_kategori; ?>" src="<?php echo base_url(); ?>assets/gambar/icon_category/<?php echo $nama_kategori; ?>.png" style="width:200px;height:200px;">
                </a>
            </div>
    <?php       
        endforeach;
    ?>
    <div id="pagination" class="col-md-10 col-md-offset-1">
        <center>
            <?php echo $pagination; ?>
        </center>
    </div>
</div>

,最后一个是我的模型ui_model.php(model / ui_model.php)

public function get_all_category($num ,$offset){
        $query = $this->db->get('kategori_wisata' , $num , $offset); 
        return $query->result_array();
    }

1 个答案:

答案 0 :(得分:0)

当我尝试使用您的代码时,$config只有4个项目数组,因此不包含配置文件中的那些变量。