首页 > CMS建站 > 织梦DEDE > 正文

织梦dedecms搜索没有结果时在搜索结果页添加友好提示的实现方法

2020-07-02 22:10:48
字体:
来源:转载
供稿:网友
这篇文章主要为大家详细介绍了织梦dedecms搜索没有结果时在搜索结果页添加友好提示的实现方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,有需要的朋友可以收藏方便以后借鉴。

搜索功能!输入的关键字没有搜索到文章,怎么在搜索结果页上做一个文字友好提示。比如提示 没有搜索到你要找的关键词的内容。

在织梦,搜索默认没有结果就是空白的,如果想美化或给用户一些文字提示,可以修改文件来达到目的。

修改include/arc.searchview.class.php 

查找:

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

在下面添加代码:

if($artlist==''){$artlist='<li style="background-color:#f5f5f5; height:50px;padding: 12px 0 0 5px;font-size: 16px;">抱歉,暂无<span style="background-color:#ffffff;color:#dd201a;"><strong>';$artlist .= $this->Keyword;$artlist .= '</strong></span><span style="color: black;">的搜索结果。</span><span style="color: black;">请尝试其他关键词的搜索,如:织梦模板...</span></li>';}

完成搜索结果页面的友好提示。

织梦DedeCMS搜索页面搜索结果总数调用方法

由于dedecms原生不支持搜索页面结果总数的调用,所以得自己修改文件来支持了。搜索页面调用的代码全在/include/arc.searchview.class.php里,我们先打开/include/arc.searchview.class.php文件,然后按下面步骤修改文件:

第一步:在

else if($tagname=="pagelist"){$list_len = trim($ctag->GetAtt("listsize"));if($list_len==""){$list_len = 3;}$this->dtp->Assign($tagid,$this->GetPageListDM($list_len));}

下面添加:

else if($tagname=="itemcount"){$list_len = trim($ctag->GetAtt("listsize"));if($list_len==""){$list_len = 3;}$this->dtp->Assign($tagid,$this->GetItemsCountDM($list_len));}

第二步:在

/*** 获得当前的页面文件的url** @access public* @return string*/

前面添加下面代码:

//————//搜索输出总量//————function GetItemsCountDM($list_len){global $oldkeyword;$pagenow = ($this->PageNo-1) * 10 + 1;$pagenows = $this->PageNo*10; //当结果超过限制时,重设结果页数if($this->TotalResult > $this->SearchMaxRc){$totalpage = ceil($this->SearchMaxRc/$this->PageSize);}$plist .= $this->TotalResult;return $plist;}

第三步: 在要显示的地方加入 {dede:itemcount listsize='4'/} 即可 。

至此,我们搜索功能就比较完善,就添加了搜索结果页面的友好提示和结果总条数。

以上就是织梦dedecms搜索没有结果时在搜索结果页添加友好提示的实现方法的全部内容,希望对大家的学习和解决疑问有所帮助,也希望大家多多支持错新网。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表