1

Codeigniter 分页create_link()在视图页面上显示空白..

当我从控制器功能回显分页create_link时,它显示完美,但是当我尝试在视图页面上回显它时,它显示为空白。

谢谢。

//下面是我的代码控制器代码

    $row=$this->city_model->city_list();
    //pagination start here
    $config['base_url'] = 'http://localhost/edu/index.php/admin/city/index';
    $config['total_rows'] = count($row);
    $config['per_page'] = 10; 
    $config['num_links']=20;
    $this->pagination->initialize($config); 
    $row=$this->city_model->city_listing($config['per_page'],$this->uri->segment(4));
    //pagination end here

    //This will generate data into table format
    //$row=$this->city_model->city_list();
    $tmpl = array ( 'table_open'  => '<table class="data display datatable">' );
    $this->table->set_heading('City Name','State', 'Edit', 'Delete');   
    $this->table->set_template($tmpl);
    foreach($row as $r)
    {
         $edit  = anchor('javascript:void(0)','Edit','id="overlay_dialog"');    
         $del  = anchor('/admin/city/deleteCity/'.$r->city_id ,'Delete');
         $this->table->add_row($r->city_name,$r->stateName,$edit,$del);
    }
    $data['city_table']=$this->table->generate();

     echo $this->pagination->create_links();//pagnigation links work here

    $this->load->view('admin/header');
    $this->load->view('admin/leftmenu');
    $this->load->view('admin/city',$data);
    $this->load->view('admin/footer');

//这是我的视图代码

echo $city_table; 
echo $this->pagination->create_links();
4

2 回答 2

1

您应该在控制器中设置分页链接变量:

$data['links'] = $this->pagination->create_links();

并将其输出到您视图中的某个位置:

<?php echo $links; ?>
于 2013-06-08T13:55:57.527 回答
0

在控制器中,您必须从此处PaginationLink执行所有分页代码。当它工作时,你必须在你的视图中粘贴下面的代码。它将创建分页链接。

<?php echo $this->pagination->create_links() ?>
于 2019-03-19T11:40:15.370 回答