CODEIGNITER:codeigniter中的分页仍然有下一个事件,但只有一页

时间:2015-11-27 04:27:06

标签: php codeigniter pagination

这是我的分页设置

$pagination_config = array(
        // pagination settings
        'base_url' => site_url('lab/hasil_rawat_jalan'),
        'total_rows' => $jawaban_lab->total_row(),
        'suffix' => '?column=' . $column_name . '&value=' . $value,
        'reuse_query_string' => FALSE,
        'per_page' => $per_page,
        // 'uri_segment' => 3,
        'num_links' => floor(count($labs) / 15),
        // config for bootstrap pagination 
        'full_tag_open' => '<ul class="pagination">',
        'full_tag_close' => '</ul>',
        'first_link' => false,
        'last_link' => false,
        'first_tag_open' => '<li>',
        'first_tag_close' => '</li>',
        'prev_link' => '&laquo',
        'prev_tag_open' => '<li class="prev">',
        'prev_tag_close' => '</li>',
        'next_link' => '&raquo',
        'next_tag_open' => '<li>',
        'next_tag_close' => '</li>',
        'last_tag_open' => '<li>',
        'last_tag_close' => '</li>',
        'cur_tag_open' => '<li class="active"><a href="#">',
        'cur_tag_close' => '</a></li>',
        'num_tag_open' => '<li>',
        'num_tag_close' => '</li>'
    );

我的问题是为什么分页仍显示下一页的链接尽管我将'num_links'设置为0,如下所示:

enter image description here

如何删除下一页的链接?

1 个答案:

答案 0 :(得分:0)

控制器

public function all_post()
{
    $data = array();
    $this->load->library('pagination');
    $config['base_url'] = base_url() . 'lab/hasil_rawat_jalan/';
    $config['total_rows'] = $this->db->count_all('posts');
    $config['per_page'] = '6';
    $config['full_tag_open'] = '<ul class="pagination">';
    $config['full_tag_close'] = '</ul>';
    $config['first_link'] = false;
    $config['last_link'] = false;
    $config['first_tag_open'] = '<li>';
    $config['first_tag_close'] = '</li>';
    $config['prev_link'] = 'Prev';
    $config['prev_tag_open'] = '<li class="prev">';
    $config['prev_tag_close'] = '</li>';
    $config['next_link'] = 'Next';
    $config['next_tag_open'] = '<li>';
    $config['next_tag_close'] = '</li>';
    $config['last_tag_open'] = '<li>';
    $config['last_tag_close'] = '</li>';
    $config['cur_tag_open'] = '<li class="active"><a href="#">';
    $config['cur_tag_close'] = '</a></li>';
    $config['num_tag_open'] = '<li>';
    $config['num_tag_close'] = '</li>';
    $this->pagination->initialize($config);
    $data['all_blogs']=$this->w_model->view_publish_blog($config['per_page'], $this->uri->segment(4));
    $data['maincontent'] = $this->load->view('cat_content',$data, true);
    $this->load->view('home', $data);
}

<强>模型

function view_publish_blog($per_page, $offset){
    $this->db->select('*');
    $this->db->from('posts');
    $this->db->where('status',1);
    $this->db->order_by('post_id','desc');
    $query_result=$this->db->get('', $per_page, $offset);
    $result=$query_result->result();
    return $result; 
}