我有一個代碼點擊分頁鏈接功能正常,但如果我點擊一個鏈接,特定鏈接不顯示爲活動鏈接。 我的代碼如下CodeIgniter分頁先前和活動鏈接不工作
function viewcategory($name) {
$this->load->database();
$this->load->model('categorypostmod');
$page = $this->uri->segment(5);
$this->load->helper("url");
$this->load->library('table');
$this->load->model("site_model");
$this->load->helper('form');
$this->load->library('pagination');
$config['base_url'] = "http://localhost/b3/index.php/CategoryPost/viewcategory/" . $name . "/page/";
$config['per_page'] = 2;
$config['num_links'] = 5;
log_message('info', 'count is ' . $this->categorypostmod->getCategorycount($name));
$config['total_rows'] = $this->categorypostmod->getCategorycount($name);
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['use_page_numbers'] = TRUE;
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<li class="next page">';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = ' 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>';
$data['query'] = $this->categorypostmod->getCategorypost($name, $config['per_page'], $this->uri->segment(5));
$records = $this->db->get('post', $config['per_page'], $this->uri->segment(5));
$this->pagination->initialize($config);
$this->load->helper("url");
$this->load->view('script');
$this->load->view('head');
$this->load->view('cat_content_list', $data);
$this->load->view('aside');
$this->load->view('bottom');
}
控制器名稱是categorypost,請幫我相同的代碼工作的其他控制器,我覺得我缺少的是如何創建的鏈接工作,看起來像我,CI無法獲得被點擊的鏈接是主動鏈接,請幫助我解決這個問題。
第一個錯誤的工作:要裝入'$這個 - >負載>幫手( 「URL」);'兩次。嘗試將所有'load()'函數放在最上面。 – CodeGodie 2015-04-01 18:04:59
在你的'base_url'結尾刪除尾部正斜槓'/' – CodeGodie 2015-04-01 18:12:04
爲什麼你的URL中有'page'參數'$ config ['base_url'] =「http:// localhost/b3/index。 php/CategoryPost/viewcategory /「。 $名稱。 「/ page /」'? – CodeGodie 2015-04-01 18:37:07