数字化技能提升教程,数字化时代生存宝典

数字化百科 / 词条 / EXCMS 搜索文件

EXCMS 搜索文件

查看全部词条命名空间:Main

导航:返回上一页


EXCMS的模块搜索文件为:search.php,用于站内搜索包括按关键字搜索和高级搜索。

代码

001	,trim($_GET[$EXCMS['search']['querystring_keywords']])));
040	$_PAGE['search']['category'] = $_GET[$EXCMS['search']['querystring_category']];
041	$_PAGE['search']['advanced'] = $_GET[$EXCMS['search']['querystring_advanced']];
042	 
043	$allkeywords = $_GET[$EXCMS['search']['querystring_allkeywords']];
044	$completekeywords = $_GET[$EXCMS['search']['querystring_completekeywords']];
045	$arbitrarykeywords = $_GET[$EXCMS['search']['querystring_anykeywords']];
046	$notin = $_GET[$EXCMS['search']['querystring_notin']];
047	 
048	//加载搜索类,创建搜索对象
049	excms_import('EXCMS.search.Search');
050	$_PAGE['search']['class'] = new Search();
051	 
052	//设置搜索分类
053	$_PAGE['search']['class']->setCategory($_PAGE['search']['category']);
054	 
055	//获取搜索分类
056	$_PAGE['search']['category'] = $_PAGE['search']['class']->getCategory();
057	 
058	//检查搜索关键字是否为空
059	if($_PAGE['search']['keywords'] !=  || $allkeywords!= || $completekeywords!= || $arbitrarykeywords!= || $notin!=){
060	    //获取参数
061	    $pagesize = $_GET[$EXCMS['search']['querystring_pagesize']];
062	    $pageon = excms_func_page_decode($_GET[$EXCMS['search']['querystring_pageon']]);
063	    $_PAGE['search']['date'] = $_GET[$EXCMS['search']['querystring_date']];
064	    $_PAGE['search']['keywordslocation'] = $_GET[$EXCMS['search']['querystring_keywordslocation']];
065	    $orderby = $_GET[$EXCMS['search']['querystring_orderby']];
066	    //设置是否是高级搜索
067	    $_PAGE['search']['class']->setAdvanced($_PAGE['search']['advanced']);
068	    //设置搜索关键字
069	    $_PAGE['search']['class']->setKeywords($_PAGE['search']['keywords']);   
070	     
071	    /**
072	     * 高级搜索相关参数
073	     */
074	    //包含以下全部的关键词
075	    $_PAGE['search']['class']->setAllKeywords($allkeywords);
076	    //包含以下的完整关键词
077	    $_PAGE['search']['class']->setCompleteKeywords($completekeywords);
078	    //包含以下任意一个关键词
079	    $_PAGE['search']['class']->setArbitraryKeywords($arbitrarykeywords);
080	    //不包括以下关键词
081	    $_PAGE['search']['class']->setNotIn($notin);
082	    //限定要搜索的网页的时间是
083	    $_PAGE['search']['class']->setDate($_PAGE['search']['date']);
084	    //查询关键词位于
085	    $_PAGE['search']['class']->setKeywordsLocation($_PAGE['search']['keywordslocation']);
086	    //设置排序
087	    $_PAGE['search']['class']->setOrderby($orderby);
088	    //选择搜索结果显示的条数
089	    $_PAGE['search']['class']->setPagesize($pagesize);
090	    //设置当前页
091	    $_PAGE['search']['class']->setPageon($pageon);
092	     
093	    if($_PAGE['search']['advanced']){
094	        //获取关键字
095	        $_PAGE['search']['keywords'] = $_PAGE['search']['class']->getWords();
096	    }
097	     
098	    //按搜索分类设定模板
099	    $tpl = $_PAGE['search']['category']['template'];
100	    $tpl = $tpl ? $tpl : 'search.html';
101	}else{
102	    //空搜索模板
103	    $tpl = $_PAGE['search']['advanced'] ? 'search_advanced.html' : 'search_blank.html';
104	}
105	 
106	//输出模板
107	excms_func_templateDisplay($tpl);
108	 
109	?>

代码修改

如果站点不需要高级搜索,可以去除高级搜索的相关参数,以及部分代码,更改后的结果如下
01	,trim($_GET[$EXCMS['search']['querystring_keywords']])));
40	$_PAGE['search']['category'] = $_GET[$EXCMS['search']['querystring_category']];
41	 
42	//加载搜索类,创建搜索对象
43	excms_import('EXCMS.search.Search');
44	$_PAGE['search']['class'] = new Search();
45	 
46	//设置搜索分类
47	$_PAGE['search']['class']->setCategory($_PAGE['search']['category']);
48	 
49	//获取搜索分类
50	$_PAGE['search']['category'] = $_PAGE['search']['class']->getCategory();
51	 
52	//检查搜索关键字是否为空
53	if($_PAGE['search']['keywords'] != ){
54	    //获取参数
55	    $pagesize = $_GET[$EXCMS['search']['querystring_pagesize']];
56	    $pageon = excms_func_page_decode($_GET[$EXCMS['search']['querystring_pageon']]);
57	 
58	    //设置搜索关键字
59	    $_PAGE['search']['class']->setKeywords($_PAGE['search']['keywords']);   
60	    //选择搜索结果显示的条数
61	    $_PAGE['search']['class']->setPagesize($pagesize);
62	    //设置当前页
63	    $_PAGE['search']['class']->setPageon($pageon);
64	    //按搜索分类设定模板
65	    $tpl = $_PAGE['search']['category']['template'];
66	    $tpl = $tpl ? $tpl : 'search.html';
67	}else{
68	    //空搜索模板
69	    $tpl = 'search_blank.html';
70	}
71	 
72	//输出模板
73	excms_func_templateDisplay($tpl);
74	 
75	?>

页面参数$_PAGE可以自由修改,根据模板的需要来增加和修改页面参数。模板中可自由调用页面的参数,例如:{$_PAGE.title}显示页面标题。

category:EXCMS