我有一个代码点击分页链接功能正常,但如果我点击一个链接,特定链接不显示为活动链接。 我的代码如下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