Codeigniter中的错误分页 [英] error pagination in codeigniter
本文介绍了Codeigniter中的错误分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在codeigniter中进行分页,但是当我在config/pagination.php中进行组合时,则无法工作.我使用语义UI来做到这一点.
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.
这是config/pagination.php
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>';
控制器
private function _kegiatan()
{ $ this-> load-> model('mkegiatan');
{ $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();
}
通话中查看
<div class="pagination"><?php echo $pagination; ?></div>
请帮我做什么.
谢谢.
推荐答案
像这样更改您的配置
$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);
}
这篇关于Codeigniter中的错误分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文