これが私のコントローラーです:
class Comment extends CI_Controller {
function article() {
$this->load->library('pagination');
$this->load->model('comment_m');
$id=$this->uri->segment(3);
$config['base_url'] = 'http://localhost/ci/CodeIgniter_2.1.3/index.php/comment/article/'.$id;
$config['total_rows'] = $this->db->get('comment_article')->num_rows();
$config['per_page'] = 5;
$config['num_links'] = 5;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
echo $this->uri->segment(4);
$data['c_review'] = $this->comment_m->getarticle($id, $config['per_page'], $this->uri->segment(4));
$this->load->view('comment_v', $data);
}
}
これが私のモデルです:
class Comment_m extends CI_Model{
function getarticle($id,$limit,$start) {
$this->db->select('name, content');
$this->db->from('comment_article');
$this->db->where('article_id', $id);
$this->db->limit($limit, $start);
$q = $this->db->get();
if($q->num_rows() > 0) {
foreach ($q->result() as $c_review) {
$data[] = $c_review;
}
return $data;
}
}
}
記事が10個以下(2ページのみ)の場合、ページ付けは正常に機能しますが、3番目のページ付けリンクがある場合、3番目のリンクは不可解になり、アンカータグではありません。私は他のページで同じページ付けを使用しましたが、これは正常に機能していますが、これがこの問題を引き起こしています。
これがページ付けされたページの写真へのリンクです。ここでは、アクティブなページがまだ1であるのに、強調表示されたページは3であるため、3番目のページはクライニングできません。
そして、これは私がこのページネーションでは達成できない他の実装ですが、これが私が望むものです:ここでは、現在のページが1番目で、ページごとに5つのアイテムがある合計13のアイテムがあります。