织梦dedecms搜索栏目功能

一.需要把/include/arc.searchview.class.php,复制一份,重命名为arc.searchview_type.class.php

然后,把新文件中的class SearchView修改为class SearchView_type

1.在plus/serach.php中找到
require_once(DEDEINC."/arc.searchview.class.php");

改成

require_once(DEDEINC."/arc.searchview_type.class.php");
require_once(DEDEINC."/arc.searchview.class.php");
2.找到
$sp = new SearchView($typeid,$keyword,$orderby,$channeltype,$searchtype,$starttime,$pagesize,$kwtype,$mid);

改成

$sp = new SearchView_type($typeid,$keyword,$orderby,$channeltype,$searchtype,$starttime,$pagesize,$kwtype,$mid,$typeimg);
//$sp = new SearchView($typeid,$keyword,$orderby,$channeltype,$searchtype,$starttime,$pagesize,$kwtype,$mid);

把文章的实例搜索注释掉只保留栏目的实例搜索
如果需要文章的搜索,把注释去掉即可。(建议做小说站只保留栏目的搜索)

二.arc.searchview_type.class.php的修改部分

1.把function CountRecord()整体替换为
/**
 *  统计列表里的记录
 *
 * @access    public
 * @return    string
 */
function CountRecord(){
    if(isset($GLOBALS['PageNo']))
    {
        $this->PageNo = intval($GLOBALS['PageNo']);
    }
    else
    {
        $this->PageNo = 1;
    }
        $qq=$this->Keyword;
         $row = $this->dsql->GetOne("SELECT count(id) as c FROM `#@__arctype` WHERE ishidden=0 and typename like '%$qq%' ");
        $this->TotalResult=$row['c'];
}
2.修改 function GetArcList (),在这里找到$query =
$query = "SELECT arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,
act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath
            FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` act ON arc.typeid=act.id
           WHERE {$this->AddSql} $ordersql LIMIT $limitstart,$row";       

替换为

$qq=$this->Keyword;
$query ="SELECT * FROM `#@__arctype` WHERE ishidden=0 and typename like '%$qq%' LIMIT $limitstart,$row";
3.然后在
$row["id"]=$row["aid"];

这句的下面增加

$row["typeurl"] ='/plus/list.php?tid='.$row["id"];//方便前台调用栏目地址,其它row不需要的字段删除一下.比如$row["money"]等

search.htm模板上显示结果方法为

{dede:list perpage='20'}
  
  • [field:typename/]

    栏目描述:[field:description/]

  • {/dede:list}

    搜索按钮为

     

    原文链接:https://blog.csdn.net/viqecel/article/details/80058449······viqecel
    https://blog.csdn.net/wei741094234/article/details/102872414······wei741094234

    你可能感兴趣的:(织梦dedecms搜索栏目功能)