1

CodeIgniter2.xのページネーションに問題があります。これはControllerのコードです。

$config['base_url'] = base_url().'crawl/all/'.$file.'/';
$config['total_rows'] = $total;
$config['per_page'] = 10;
$config['num_links'] = 3;
$config['uri_segment'] = 4;
$config['full_tag_open'] = '<ul id="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open'] = '<li class="next">';
$config['next_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active">';
$config['cur_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';

$this->pagination->initialize($config);

$data['total'] = $total;
$data['path'] = $this->path.'/'.$file;
$data['file'] = $file;
$data['batch'] = $this->batch->all($file, $config['per_page'], $config['uri_segment']);

私の見解は次のとおりです。<?php echo $this->pagination->create_links() ?>

ページ番号のリンクは機能しますが(1から2などに移動します)、データが正しく表示されません。

4

1 に答える 1

0

ページをクリックすると、ページはクエリ文字列として送信する必要がなく、構成に追加する必要があるため、ページIDを見逃しています。

コード例:

$limit = $this->config->item('paging_limit');
$offset = $id * $limit;

$data['rows'] = $this->news_model->get_moreNews($limit, $offset);
$config["image_url"]=$this->config->item("base_url");
$config['base_url'] = base_url().'/news/morenews/';
$config['total_rows'] = $this->db->count_all('news');
$config['per_page'] = $limit;
$config['chapter'] = $this->input->post('chapter');
$config['page'] = $id;

$this->paginationsimple->initialize($config);
$paginator=$this->paginationsimple->create_links();

$data['paginator'] = $paginator;
于 2012-06-20T07:14:27.947 に答える