1

我在 CodeIgniter 2.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,因为当您单击页面时,页面 no 必须作为查询字符串发送,并且必须为配置添加。

示例代码:

$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 回答