搜索功能!输入的关键字没有搜索到文章,怎么在搜索结果页上做一个文字友好提示。比如提示 没有搜索到你要找的关键词的内容。
在织梦,搜索默认没有结果就是空白的,如果想美化或给用户一些文字提示,可以修改文件来达到目的。
修改include/arc.searchview.class.php
查找:

1
$this->dsql->FreeResult("al");

在下面添加代码:
1
if($artlist==''){
2
$artlist='<li style="background-color:#f5f5f5; height:50px;padding: 12px 0 0 5px;font-size: 16px;">抱歉,暂无<span style="background-color:#ffffff;color:#dd201a;"><strong>';
3
$artlist .= $this->Keyword;
4
$artlist .= '</strong></span><span style="color: black;">的搜索结果。</span><span style="color: black;">请尝试其他关键词的搜索,如:织梦模板...</span></li>';
5
}
完成搜索结果页面的友好提示。
织梦DedeCMS搜索页面搜索结果总数调用方法
由于dedecms原生不支持搜索页面结果总数的调用,所以得自己修改文件来支持了。搜索页面调用的代码全在/include/arc.searchview.class.php里,我们先打开/include/arc.searchview.class.php文件,然后按下面步骤修改文件:
第一步:在
1
else if($tagname=="pagelist"){
2
$list_len = trim($ctag->GetAtt("listsize"));
3
if($list_len=="")
4
{
5
$list_len = 3;
6
}
7
$this->dtp->Assign($tagid,$this->GetPageListDM($list_len));
8
}
下面添加:
1
else if($tagname=="itemcount"){
2
$list_len = trim($ctag->GetAtt("listsize"));
3
if($list_len=="")
4
{
5
$list_len = 3;
6
}
7
$this->dtp->Assign($tagid,$this->GetItemsCountDM($list_len));
8
}
第二步:在
1
/**
2
* 获得当前的页面文件的url
3
*
4
* @access public
5
* @return string
6
*/
前面添加下面代码:

01
//————
02
//搜索输出总量
03
//————
04
function GetItemsCountDM($list_len){
05
global $oldkeyword;
06
$pagenow = ($this->PageNo-1) * 10 + 1;
07
$pagenows = $this->PageNo*10; //当结果超过限制时,重设结果页数
08
if($this->TotalResult > $this->SearchMaxRc)
09
{
10
$totalpage = ceil($this->SearchMaxRc/$this->PageSize);
11
}
12
$plist .= $this->TotalResult;
13
return $plist;
14
}
第三步: 在要显示的地方加入 {dede:itemcount listsize='4'/} 即可 。
至此,我们搜索功能就比较完善,就添加了搜索结果页面的友好提示和结果总条数。

免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。