|
Contrller代码
PHP复制代码
public function search_form ($page=0)
{
$this->load->library('session');
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$data['user_name']=$this->session->userdata('user_name');
$data['board_name']=$this->data_title_real;
$data['realname']=$this->data_title_index;
$data['title']=$this->data_title_search;
$data['description']=$this->data_description;
$data['more']=$this->data_more;
$this->form_validation->set_rules('search', '搜寻内容', 'required|trim|xss_clean|htmlspecialchars');
$this->form_validation->set_message('required', '<font color="red">对不起,%s栏位属於必填栏位,请重新检查。</font>');
$this->form_validation->set_error_delimiters('<div class="alert alert-error"><img src="img/error.png"> ', '</div>');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('header_view',$data);
$this->load->view('search_view');
$this->load->view('footer_view');
}
else
{
if(!is_numeric($page)){
exit;
}
$this->load->model('Question_model');
$this->load->database();
//Pagination
$this->load->library('pagination');
$config['base_url'] = '/index.php/question/search_form/';
$config['total_rows'] = $this->Question_model->count_search($this->input->post('search'));
$config['per_page'] = 10;
$config['first_link'] = '第一页';
$config['last_link'] = '最後一页';
$config['full_tag_open'] = '<li>';
$config['full_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li><a>';
$config['cur_tag_close'] = '</li></a>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['next_link'] = '下一页»';
$config['prev_link'] = '«上一页';
$data['result']=$this->Question_model->search_question($this->input->post('search'),$page,$page+10);
$this->pagination->initialize($config);
$data['pagelink'] = $this->pagination->create_links();
//Pagination
$this->load->view('header_view',$data);
$this->load->view('searchResult_view',$data);
$this->load->view('footer_view');
}
}
复制代码
问题所在::当进入搜索结果页面时,只要点击分页类产生出来的分页连结,又会回到一开始的搜索页面,估计跟表单验证类有关,要怎麽用简洁的方法解决? |
|