你好,我有以下代码,笨分页不渲染分页链接
$this->load->library('pagination');
$this->data['products'] = $this->products_model->get_products_and_category($this->uri->segment(4));
$config['base_url'] = base_url()."admin/products/manage/";
$config['total_rows'] = $this->db->get('products')->num_rows();
$config['per_page'] = 20;
$config['full_tag_open'] = '<div class="btn-group">';
$config['full_tag_close'] = '</div>';
$config['anchor_class'] = 'class="btn" ';
$config['cur_tag_open'] = '<div class="btn">';
$config['cur_tag_close'] = '</div>';
$config['uri_segment'] = 4;
$this->pagination->initialize($config);
$this->data['pagination'] = $this->pagination->create_links();
$this->template->build('admin/products/index', $this->data);
这是由get_products_and_category($this->uri->segment(4))
运行看起来像这样的查询,
public function get_products_and_category($offset=0) {
$this->db->select('products.product_id, products.product_title, products.product_created, products.parent_category, categories.category_id, categories.category_title')
->from('products')
->join('categories' , 'products.parent_category = categories.category_id', 'left')
->order_by('products.product_title', 'ASC')
->limit(25, $offset);
$query = $this->db->get();
return $query->result_array();
}
有25个结果在我的表,我想每页显示20个,所以通过我的数学分页课程应该创建2个链接(第1页和第2页)第一页应该有20个结果,第二个应该有4个结果,但是我没有收到所有的链接,我做错了什么?
我假设你在模板中回显数据['分页'],对吧? – IsisCode
Absolutley - 那对我来说真的很愚蠢 – Udders
@ sico87,有时候人们犯了愚蠢的错误,总是值得提问,尤其是因为我们没有看到你的代码。 – Jakub