error pagination in codeigniter

会有一股神秘感。 提交于 2019-12-12 04:32:00

问题


i want to make pagination in codeigniter its work but when i make mookup in config/pagination.php its not working. i make semantic-ui to make this.

this is config/pagination.php

$config['first_link'] = FALSE;
$config['last_link'] = FALSE;
$config['next_tag_open'] = '<a>';
$config['next_tag_close'] = '</a>';
$config['prev_tag_open'] = '<a>';
$config['prev_tag_close'] = '</a>';
$config['cur_tag_open'] = '<a class="item" href="#">';
$config['cur_tag_close'] = '</a>';
$config['num_tag_open'] = '<a>';
$config['num_tag_close'] = '</a>';

controller

private function _kegiatan()

{ $this->load->model('mkegiatan');

//$this->db->where('tanggal_kegiatan', $slug);
//$this->db->where('id', $id);
$count = $this->db->count_all_results('kegiatan_ukm');
var_dump($count);

// Set up pagination
$perpage = 2;
if ($count > $perpage) {
    $this->load->library('pagination');
    $config['base_url'] = site_url($this->uri->segment(1) . '/');
    $config['total_rows'] = $count;
    $config['per_page'] = $perpage;
    $config['uri_segment'] = 2;
    $config['first_page'] = 'Awal';
    $config['last_page'] = 'Akhir';
    $config['next_page'] = '&laquo;';
    $config['prev_page'] = '&raquo;';
    $this->pagination->initialize($config);
    $this->data['pagination'] = $this->pagination->create_links();
    $offset = $this->uri->segment(2);
}
else {
    $this->data['pagination'] = '';
    $offset = 0;
}
var_dump($this->data['pagination']);


//$this->db->where('tanggal_kegiatan <=', date('Y-m-d'));
$this->db->limit($perpage, $offset);
$this->data['kegiatan'] = $this->mkegiatan->get_kegiatan();

}

call in view

<div class="pagination"><?php echo $pagination; ?></div>

please help me what to do.

thank you.


回答1:


change your config like this

$config ['pag'] = array(
'full_tag_open' => '<div class=>"ui pagination menu">',
'full_tag_close' => '</div>',
'first_link' => FALSE,
'last_link' => FALSE,
'first_tag_open' => '<a class=>"item>',
'first_tag_close' => '</a>',
'last_tag_open' => '<a class=>"item>',
'last_tag_close' => '</a>',
'next_tag_open' => '<a class=>"icon item"><i class=>"icon right arrow">',
'next_tag_close' => '</i></a>',
'prev_tag_open' => '<a class=>"item">',
'prev_tag_close' => '</a>',
'cur_tag_open' => '<a class=>"active" href=>"#">',
'cur_tag_close' => '</a>',
'num_tag_open' => '<a class=>"icon item"><i class=>"icon left arrow">',
'num_tag_close' => '</i></a>'
);

and you should load config in controller

if ($count > $perpage) {
$this->load->library('pagination');
$this->load->config('pagination');

$config = $this->config->item('pag')   

$config['base_url'] = site_url($this->uri->segment(1) . '/');
$config['total_rows'] = $count;
$config['per_page'] = $perpage;
$config['uri_segment'] = 2;
$config['first_page'] = 'Awal';
$config['last_page'] = 'Akhir';
$config['next_page'] = '&laquo;';
$config['prev_page'] = '&raquo;';
$this->pagination->initialize($config);
$this->data['pagination'] = $this->pagination->create_links();
$offset = $this->uri->segment(2);
}


来源:https://stackoverflow.com/questions/23032561/error-pagination-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!