2013-03-02 82 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 
    } 
}