doucheng9058 2013-04-22 07:34
浏览 58
已采纳

codeigniter分页不显示链接

i currently working on a project using codeigniter + twitter bootstrap,i tried to implement the pagination in it, but when i echo links in the view page it displays nothing,i have pasted the code below, i also used this code in my previous project also there it is working fine,but now it is not , i cant figure out the issue,i hope someone give me a suggestion.
This is my index function,

    $this->load->helper('url'); 
    $this->load->model('albums');
    $this->load->library('pagination');

    $config = array();
    $config["base_url"] = base_url() . "admin/gallery";
    $config["total_albums"] = $this->albums->all_albums_count();
    $config["per_page"] = 2;
    $config['num_links'] = 5;
    $config["uri_segment"] = 3;


    $config['full_tag_open'] = '<div class="pagination"><ul>';
    $config['full_tag_close'] = '</ul></div><!--pagination-->';
    $config['first_link'] = '&laquo; First';
    $config['first_tag_open'] = '<li class="prev page">';
    $config['first_tag_close'] = '</li>';

    $config['last_link'] = 'Last &raquo;';
    $config['last_tag_open'] = '<li class="next page">';
    $config['last_tag_close'] = '</li>';

    $config['next_link'] = 'Next &rarr;';
    $config['next_tag_open'] = '<li class="next page">';
    $config['next_tag_close'] = '</li>';

    $config['prev_link'] = '&larr; Previous';
    $config['prev_tag_open'] = '<li class="prev page">';
    $config['prev_tag_close'] = '</li>';

    $config['cur_tag_open'] = '<li class="active"><a href="">';
    $config['cur_tag_close'] = '</a></li>';

    $config['num_tag_open'] = '<li class="page">';
    $config['num_tag_close'] = '</li>';


    $this->pagination->initialize($config);

    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
    $data['query'] = $this->albums->get_all_albums($config["per_page"], $page);


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

    $data['albumcount'] = $config["total_albums"];
    var_dump($data['links']);
    var_dump($config);
    $this->load->view('layouts/admin_header');
    $this->load->view('admin/gallery_view', $data);
    $this->load->view('layouts/admin_footer');

in my view file , i used

 <?php echo $links; ?>

but it displays me nothing,so i have use var_dump() in the controller to know the result,

var_dump($data['links']);

it gives: string(0) ""

var_dump($config);

it gives :

array(23) { ["base_url"]=> string(41) "http://localhost/sch_manage/admin/gallery" ["total_albums"]=> int(3) ["per_page"]=> int(2) ["num_links"]=> int(5) ["uri_segment"]=> int(3) ["full_tag_open"]=> string(28) "
    " ["full_tag_close"]=> string(28) "
    " ["first_link"]=> string(13) "« First" ["first_tag_open"]=> string(22) "
    " ["first_tag_close"]=> string(5) "
    " ["last_link"]=> string(12) "Last »" ["last_tag_open"]=> string(22) "
    " ["last_tag_close"]=> string(5) "
    " ["next_link"]=> string(11) "Next →" ["next_tag_open"]=> string(22) "
    " ["next_tag_close"]=> string(5) "
    " ["prev_link"]=> string(15) "← Previous" ["prev_tag_open"]=> string(22) "
    " ["prev_tag_close"]=> string(5) "
    " ["cur_tag_open"]=> string(30) "
    " ["cur_tag_close"]=> string(9) "
    " ["num_tag_open"]=> string(17) "
    " ["num_tag_close"]=> string(5) "
    " }

In my view page i use <?php echo $albumcount; ?> it displays total album count correctly. and album limit also working fine i.e. $config["per_page"] = 2; but when i echo pagination links ,they are not showing.

  • 写回答

2条回答 默认 最新

  • douceng7070 2013-04-22 07:49
    关注

    You are passing the in the every alboum count as total_albums but the pagination library is looking for total_rows.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog