2013-04-22 84 views
0

我目前正在使用codeigniter + twitter引導項目工作,我試圖在其中實現分頁,但是當我在視圖頁面中回顯鏈接它什麼也沒有顯示,我粘貼下面的代碼,我在我以前的項目中也使用過這個代碼,在那裏它工作正常,但現在不行,我無法弄清楚這個問題,我希望有人給我一個建議。
這是我的索引功能,codeigniter分頁不顯示鏈接

$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'); 
在我看來,文件

,我用

<?php echo $links; ?> 

,但它顯示了我什麼都沒有,所以我必須用var_dump()控制器知道結果,

var_dump($data['links']); 

它給:string(0) ""

var_dump($config); 

它給:

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) " 
    " } 

在我看來,頁面我用<?php echo $albumcount; ?>它顯示專輯總準確計數。和專輯限制也工作正常,即$config["per_page"] = 2; 但當我回顯分頁鏈接,他們沒有顯示。

+0

可能是你只有2個DATAS? – itachi 2013-04-22 07:41:43

+0

不,我有4個數據在它 – 2013-04-22 07:42:47

回答

2

你在每一個alboum計數傳遞作爲total_albumspagination library正在尋找total_rows

+0

好點!我完全錯過了。 – 2013-04-22 07:52:16

+0

嗨,tnx想通了我,你救了我一天,它現在顯示的鏈接。 – 2013-04-22 07:56:07

0
$this->load->model('reciever'); 
       $this->load->library('uri'); 
       $this->load->library('pagination'); 
       $config['base_url'] = base_url(). 'users_ci/users'; 
       $config['total_rows'] = $this->reciever->getRows(); 
       $config['per_page'] = 4; 
       $config['full_tag_open'] = '<ul class="pagination">'; 
       $config['full_tag_close'] = '</ul>';    
       $config['prev_link'] = '&laquo;'; 
       $config['prev_tag_open'] = '<li>'; 
       $config['prev_tag_close'] = '</li>'; 
       $config['next_link'] = '&raquo;'; 
       $config['next_tag_open'] = '<li>'; 
       $config['next_tag_close'] = '</li>'; 
       $config['cur_tag_open'] = '<li class="active"><a href="#">'; 
       $config['cur_tag_close'] = '</a></li>'; 
       $config['num_tag_open'] = '<li>'; 
       $config['num_tag_close'] = '</li>'; 
       $config["num_links"] = round($config["total_rows"]/$config["per_page"]); 
       $config['users']= $this->reciever->getUsers(4,$this->uri->segment(3)); 
       $this->pagination->initialize($config); 
       $config['pages'] = $this->pagination->create_links(); 
       $this->load->view('users',$config); 

並認爲你正在做

<div><?php echo $pages; ?></div>