織夢搜索指定多個欄目的文檔


織夢默認的搜索可以搜索全部欄目或者指定的搜索某一個欄目,不能搜索指定的多個欄目,需要加裝修改才能實現。

1、在搜索框表單里加個typeid提交過去

例如

<form name="formsearch" 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;

刪除這一行后,繼續找到

$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).") ";
}

完成,這樣就可以搜索指定的多個欄目的文章了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM