0

例如,我有一个链接:

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

这一切都很好,但是如果我用分页激活了搜索过滤器怎么办:

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

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

4

2 回答 2

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

这些也适合你吗?

于 2013-03-03T09:08:32.537 回答
0

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

using 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
    }
}
于 2013-03-03T10:13:52.057 回答