求助:我把CI分页用在solr索引接口上,但是翻页时记不住....
求助:我力荐老大使用CI,结果还有最后一个功能,使用solr搜索接口出来的数据做个简单搜索功能。结果:我把CI分页用在solr索引接口上,但是翻页时记不住表单传过来的input。第一页数据出来很正常,我一点第二页,$url中的$input就空了。是不是我这么写不刷新表单?这么写能每次翻页的时候刷新一下表单?function solrtest ($offset=' '){
$finput=$this->input->post('keyword');
$limits = 2;
$url="http://infoindex.las.ac.cn:8080/solr/select/?q=81_txt%3A".$finput."&version=2.2&start=".$offset."&rows=".$limits."&indent=on";
$xml = simplexml_load_file($url);
$count=$this->Sites->countSolr($xml);
$config['base_url'] = base_url().'/index.php/welcome/solrtest/';
$config['total_rows'] = $count;
$config['per_page'] = $limits;
$this->pagination->initialize($config);
$data['paginationlink']=$this->pagination->create_links();
$data['solrNewsquery']=$this->Sites->getSolr($xml,$offset,$limits);
$this->load->view('solrtest_view',$data);
}
$config['base_url'] = base_url().'/index.php/welcome/solrtest/'; 这个要把每个条件都拼接进来才会在分页的时候记住分页条件。 Hex 发表于 2012-7-2 19:53 static/image/common/back.gif
$config['base_url'] = base_url().'/index.php/welcome/solrtest/'; 这个要把每个条件都拼接进来才会在 ...
大哥啥意思?在url里把form的input写进去?能不能稍微详细点?(我觉得是不是我在用分页的时候漏了什么条件,在mysql查询的时候分页从来没有出过问题) ♂chen 发表于 2012-7-3 05:59 static/image/common/back.gif
大哥啥意思?在url里把form的input写进去?能不能稍微详细点?(我觉得是不是我在用分页的时候漏了什么条 ...
这个是很常见的思路吧:
$config['base_url'] = base_url().'/index.php/welcome/solrtest/表单input1/表单input2/表单input3/...';
就是说,如果翻页后还能保留用户点击“搜索”时候的条件,你需要把这些条件记录下来,因为 HTTP 协议本身是无状态的,用 URL 记录条件是一个方案。 Hex 发表于 2012-7-3 11:22 static/image/common/back.gif
这个是很常见的思路吧:
$config['base_url'] = base_url().'/index.php/welcome/solrtest/表单input1/表 ...
谢谢,我也是这么想的,但是我很奇怪在用来mysql翻页的时候可以记住用户form的信息呢? ♂chen 发表于 2012-7-3 15:18 static/image/common/back.gif
谢谢,我也是这么想的,但是我很奇怪在用来mysql翻页的时候可以记住用户form的信息呢? ...
你不设置是不可能记住的。。。。。 谢谢Hex,问题解决了,用了简单的redirect,吧input value 转成url value,轻松记住。
function solrsearchtes( ){
$fInput=$this->input->post('keyword');
$iType=$this->input->post('type');
redirect('scinews/solrsearchre/'.$fInput.'/'.$iType.'/');
}
页:
[1]