dreamone5156 2017-03-06 16:12
浏览 35

CodeIgniter分页链接无法呈现

In my view, the links for pagination is not rendering.It was working earlier this day, don't know what I did wrong to make the generating of links fail.

public function index() {
    $data['user'] = $this->session->userdata();
    $_SESSION['nav'] = 1;
    $this->load->library('pagination');
    $page = 2;
    $offset = $this->uri->segment(3);
    $config['uri_segment'] = 4;
    $config['base_url'] = base_url() . 'assigner/index/';
    $config['total_rows'] = $this->TasksModel->countPostedTasks();
    $config['per_page'] = $page;

    $config['full_tag_open'] = "<ul class='pagination'>";
    $config['full_tag_close'] = "</ul>";
    $config['num_tag_open'] = '<li>';
    $config['num_tag_close'] = '</li>';
    $config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
    $config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
    $config['next_tag_open'] = "<li>";
    $config['next_tagl_close'] = "</li>";
    $config['prev_tag_open'] = "<li>";
    $config['prev_tagl_close'] = "</li>";
    $config['first_tag_open'] = "<li>";
    $config['first_tagl_close'] = "</li>";
    $config['last_tag_open'] = "<li>";
    $config['last_tagl_close'] = "</li>";
    $this->pagination->initialize($config);
    $data['links'] = $this->pagination->create_links();

    $data['tasks'] = $this->TasksModel->getPostedTasks($page, $offset);
    $this->load->view('assigner/header', $data);
    $this->load->view('assigner/index', $data);
}
  • 写回答

2条回答 默认 最新

  • dsa456369 2017-03-06 20:22
    关注

    You will need to define the number of links the pagination library should show. Add this line to your code.

    $config['num_links'] = round($config['total_rows'] / $config['per_page']);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line