搜索功能!輸入的關鍵字沒有搜索到文章,怎么在搜索結果頁上做一個文字友好提示。比如提示 沒有搜索到你要找的關鍵詞的內容。
在織夢,搜索默認沒有結果就是空白的,如果想美化或給用戶一些文字提示,可以修改文件來達到目的。
修改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搜索沒有結果時在搜索結果頁添加友好提示的實現方法的全部內容,希望對大家的學習和解決疑問有所幫助,也希望大家多多支持武林網。新聞熱點
疑難解答