创新屋百科网

您现在的位置是:首页 > 站长新闻 > CMS教程 > 正文

CMS教程

dedecms织梦搜索页面单独调用搜索结果条数怎么实现?

达特2023-06-02CMS教程178

DEDE的搜索结果数量都集成在了列表分页标签里,并没有使用单独的函数来提供这个结果数量,因此对有单独调用搜索结果数量的用户来说,就有使用问题,这里提供二次开发的方法。
非常简单只要修改几个地方就行了:
第一步,打开/include/arc.searchview.class.php文件,查找代码(大概在第525行):

01 else if($tagname=="pagelist")
02  
03 {
04  
05 $list_len = trim($ctag->GetAtt("listsize"));
06  
07 if($list_len=="")
08  
09 {
10  
11 $list_len = 3;
12  
13 }
14  
15 $this->dtp->Assign($tagid,$this->GetPageListDM($list_len));
16  
17 }
在下面添加代码:
01 else if($tagname=="itemcount")
02  
03 {
04  
05 $list_len = trim($ctag->GetAtt("listsize"));
06  
07 if($list_len=="")
08  
09 {
10  
11 $list_len = 3;
12  
13 }
14  
15 $this->dtp->Assign($tagid,$this->GetItemsCountDM($list_len));
16  
17 }
第二步,查找代码(大概在第925行):
/**   * 获得当前的页面文件的url   *   * @access public   * @return string   */
在其上面添加下面的这段代码:

01 function GetItemsCountDM($list_len)
02  
03 {
04  
05 global $oldkeyword;
06  
07 $pagenow = ($this->PageNo-1) * 10 + 1;
08  
09 $pagenows = $this->PageNo*10; //当结果超过限制时,重设结果页数
10  
11 if($this->TotalResult > $this->SearchMaxRc)
12  
13 {
14  
15 $totalpage = ceil($this->SearchMaxRc/$this->PageSize);
16  
17 }
18  
19 $plist .= $this->TotalResult;
20  
21 return $plist;
22  
23 }
第三步,在搜索结果页模板里要显示结果条数的地方通过如下标签调用:
{dede:itemcount listsize='4'/}
这样就可以实现搜索结果页的搜索结果数量的单独调用了。

01 else if($tagname=="itemcount")
02  
03 {
04  
05 $list_len = trim($ctag->GetAtt("listsize"));
06  
07 if($list_len=="")
08  
09 {
10  
11 $list_len = 3;
12  
13 }
14  
15 $this->dtp->Assign($tagid,$this->GetItemsCountDM($list_len));
16  
17 }

发表评论

评论列表

  • 这篇文章还没有收到评论,赶紧来抢沙发吧~