Codeigniter分页视图

时间:2015-06-01 07:21:38

标签: php codeigniter view pagination

我是Codeigniter的新手,我需要找到方法。

控制器,我在这里获取数据:

<?php
class PropertyModel extends CI_Model {

function __construct()
{
    // Call the Model constructor
    parent::__construct();
}

 public function pagination()

{
$this->load->view('templates/header');
$this->load->library('pagination');
$this->load->library('table');
$config['base_url']='http://localhost/Goldenacre/property/pagination';
$config['total_rows']= $this->db->get('property')->num_rows();
$config['per_page']= 10;
$config['num_links']=5;
$this->pagination->initialize($config);



$config['total_rows']=$this->db->get('property')->num_rows();


$data['records']=$this->db->get('property',$config['per_page'],$this->uri->segment(3));

$this->load->view('listvieww',$data);

$this->load->view('templates/footer');

}

查看页面

<html>
<h1>My Pagination</h1>`

<?php echo $this->table->generate($records); ?>

<?php echo $this->pagination->create_links(); ?>

我的整个代码都是有效的,但它不符合我的要求。我需要像这样展示它。

它全部显示在一个表格中,我需要在div或<article> </article>标签或循环中显示它。

1 个答案:

答案 0 :(得分:0)

在您发送到Paging库的配置数组中,您可以添加

$config['full_tag_open'] = '<article>';
$config['full_tag_close'] = '</article>';
$this->pagination->initialize($config);

您还可以自定义第一个,最后一个,下一个,上一个和当前链接:查看此处的文档:https://ellislab.com/codeigniter/user-guide/libraries/pagination.html