codeigniter中的错误分页

时间:2014-04-12 15:44:32

标签: php codeigniter pagination semantic-ui

我想在codeigniter中对其工作进行分页,但是当我在config / pagination.php中制作mookup时,它无效。我用semantic-ui来做这个。

这是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()

{     $这 - &GT;负载&GT;模型(&#39; mkegiatan&#39);

//$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();

}

在视图中调用

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

请帮我做什么。

谢谢。

1 个答案:

答案 0 :(得分:0)

像这样更改您的配置

$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>'
);

你应该在控制器中加载配置

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);
}