问题
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'] = '«';
$config['prev_page'] = '»';
$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'] = '«';
$config['prev_page'] = '»';
$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