2013-03-02 52 views
0

我有例如链接:如何查询字符串添加到寻呼机(笨

http://mysite.com/5/5 - is page number 

,这里是一切OK,但如果我有分页激活的搜索过滤器:

http://mysite.com/5?filter=something 

这样的问题是:我怎么能查询字符串添加到寻呼机链接,留下寻呼机链接本身URI段,寻呼机链接URI段和过滤器的查询字符串,是可能的

回答

0

在?日e config.php文件中有一段代码允许您启用查询字符串。它应该看起来像这样。

$config['allow_get_array']  = TRUE; 
$config['enable_query_strings'] = FALSE; 
$config['controller_trigger'] = 'c'; 
$config['function_trigger']  = 'm'; 
$config['directory_trigger'] = 'd'; // experimental not currently in use 

这些对你来说是甚么?

0

我会建议以搜索关键字添加到cookiesession 因为笨分页使用URL段,

使用 http://mysite.com/5?filter=something会破坏部分,因为CI会认为第二个参数将是极限这将返回false,因为你的第二个URI段是5?filter=something

这是我怎么会做

public function search() 
{ 
    //config pagination 
    if($this->session->usedata('search_keyword') == false)//no search has been made 
    { 
     if($this->input->post('search_keyword')) 
     { 
      $data_to_query = $this->input->post('search_keyword'); 
      $this->session->set_userdata('search',$data_to_query); 
      // query for database when search_keyword is entered 
      $this->model->get($this->session->userdata('search')); // assuming this is your query model 
     }else{ 
      // if session search_keyword is false then no 
      // search has been made do the normal query 
     } 
    }else{ 
     // if search_keyword session is true then a search has been made 
     // use the data gathered on the session as a query parameter 
    } 
}