如何将查询字符串添加到寻呼机(codeigniter

时间:2013-03-02 19:49:06

标签: php codeigniter

我有一个链接,例如:

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

并且这一切都没问题,但如果我使用分页激活搜索过滤器该怎么办:

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

所以问题是:如何将查询字符串添加到寻呼机链接,将寻呼机链接本身保留为uri段,寻呼机链接是uri段,过滤器是查询字符串,这可能吗?

2 个答案:

答案 0 :(得分:0)

在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

这些也为你设定了什么?

答案 1 :(得分:0)

我建议将搜索到的关键字添加到cookiesession 因为codeigniter分页使用url段,

使用

http://mysite.com/5?filter=something将销毁该细分受众群,因为CI会认为第二个参数将是限制,并且由于您的第二个uri细分为5?filter=something

,因此会返回false

这是我怎么做的

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
    }
}