針對織夢高級開發(fā)教程會用到,指定欄目搜索及多個欄目合并搜索的要求?棄鬌edeCMS默認的搜索可以搜索全部欄目或者指定的搜索某一個欄目,不能搜索指定的多個欄目,需要修改后臺文件才能實現(xiàn)。
1、在搜索框表單里加個typeid提交過去
例如
<form name="search" action="/plus/search.php">
<input type="hidden" name="typeid" value="1,2,3">
</form>
2、打開/plus/search.php找到
$typeid = (isset($typeid) && is_numeric($typeid)) ? $typeid : 0;
刪除這一行后,繼續(xù)找到
$typeid = intval($typeid);
也刪除這一行
3、打開 /include/arc.searchview.class.php 找到
$ksqls[] = " typeid IN (".GetSonIds($this->TypeID).") ";
改成
//指定了多個欄目時
if( preg_match('#,#', $this->TypeID) )
{
$typeids = explode(',', $this->TypeID);
foreach($typeids as $ttid) {
$typeidss[] = GetSonIds($ttid);
}
$typeidStr = join(',', $typeidss);
$typeidss = explode(',', $typeidStr);
$typeidssok = array_unique($typeidss);
$typeid = join(',', $typeidssok);
$ksqls[] = " arc.typeid IN ($typeid) ";
}
else
{
$ksqls[] = " arc.typeid IN (".GetSonIds($this->TypeID).") ";
}
完成,這樣就可以搜索指定的多個欄目的文章了。