【发布时间】:2015-04-01 17:59:20
【问题描述】:
我有一个代码,点击分页链接功能正常,但如果我点击一个链接,该特定链接不会显示为活动链接。 我的代码如下
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 无法获取被点击的链接是一个活跃的,请帮我解决这个问题。
【问题讨论】:
-
第一个错误:您正在加载
$this->load->helper("url");两次。尝试将所有load()函数放在最顶部。 -
去掉
base_url末尾的斜杠/ -
为什么你的网址
$config['base_url'] = "http://localhost/b3/index.php/CategoryPost/viewcategory/" . $name . "/page/"中有page参数? -
@codeGodie 在视图类别中我将参数作为类别传递,例如。 html和我想在此基础上获取所有记录,所以我给了$name我在函数中使用的参数,如果我不给它,它将无法获取参数和搜索,我和你在一起吗? ?这就是你要问的?
标签: php codeigniter pagination codeigniter-url