使用CodeIgniter进行网站搜索? [英] Site search with CodeIgniter?
本文介绍了使用CodeIgniter进行网站搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要做一个简单的网站搜索与分页;任何人都可以告诉我如何做,而不影响URL结构?目前,我使用默认的CodeIgniter URL结构,我已从中移除 index.php
。任何建议?
I need to make a simple site search with pagination in it; could anyone tell me how to do it without affecting the URL structure? Currently I'm using the default CodeIgniter URL structure and I have removed index.php
from it. Any suggestions?
推荐答案
您可以使用 / search / search_term / page_number
。
按如下所示设置路线:
$route['search/:any'] = "search/index";
和你的控制器一样:
function index()
{
$search_term = $this->uri->rsegment(3);
$page = ( ! $this->uri->rsegment(4)) ? 1 : $this->uri->rsegment(4);
// some VALIDATION and then do your search
}
这篇关于使用CodeIgniter进行网站搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文