2016-04-26 43 views
2

辦機構4,分頁在發展上笨(ver.3的)的網站,出現錯誤:分頁無法正常工作。只有在第四個URL段設置分頁時纔會發生這種情況。如何在笨

我的控制器(類主)

public function category($id=NULL){ 
    $data['category'] = $this->articles_model->get_category($id); 

    $this->load->library('pagination'); 
    $config['base_url'] = base_url().'main/category/'.$id.'/'; 
    $config['total_rows'] = $this->articles_model 
     >count_all_articles(); 
    $config['per_page'] = 10; 
    $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0; 

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

    $data['articles'] = $this->articles_model-   >get_articles($config['per_page'],$page,$id); 
    $data['links'] = $this->pagination->create_links(); 
} 

鏈接喜歡的工作,但只強調第一頁。在第二頁和後續頁面上,第一頁也會突出顯示。

+0

你可以給我的網址,當你路過第四URI段? –

+0

沒有:(。它在本地 –

+0

好吧,給我的本地URL –

回答

1

只要告訴它使用4段...

$config['uri_segment'] = 4; 

這是documentation所示第一個選項。

+0

試過,不工作 –

+0

我累了設定的路線和其他東西的。這一次救了我的時間。謝謝兄弟。它的偉大的工作。 –

0

我有同樣的問題,但我解決了它,它運作良好:

//u need to get the category id from the segment #3 
$catid = $this->uri->segment(3); 

//here is the segment of pagintation 
$config["uri_segment"] = 4; 

/* 
here is the essantial work, where you should add the category id in the last of the base url 
*/ 
$config["base_url"] = base_url() . "home/category/$catid";