嗨,朋友我有這個函數來顯示所有文章,我一次又一次地爲不同的類別寫這個函數,因爲codeigniter參數與url有關,我如何傳遞參數使我可以重用這個功能嗎?如何在codeigniter php控制器函數中傳遞參數
這是我的控制器功能來顯示所有消息。
function all_news(){
//do some pagination
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/news/all_news';
$config['total_rows'] = $this->db->get('articles')->num_rows();
$config['per_page'] = 10;
$config['num_links'] = 7;
//some css for pagination
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
//initialize pagination
$this->pagination->initialize($config);
//end pagination
$data['title'] =" All News";
//for pagination
$data['query']= $this->db->order_by('id','desc');
$data['query'] = $this->db->get('articles',$config['per_page'],$this->uri->segment(3));
$this->load->vars($data);
$this->load->view('main/all_news');
}