织梦在搜索结果页面并没有构造单独的函数来实现调用结果数量,结果数都集成在列表分页标签里了,如果我们需要这个数量的单独调用,就要进行二次开发了。
其实很简单,教大家如何实现:
第一步,打开/include/arc.searchview.class.php文件,查找代码(大概在第525行):
1 |
else if ($tagname== "pagelist" ) |
3 |
$list_len = trim($ctag->GetAtt( "listsize" )); |
8 |
$this->dtp->Assign($tagid,$this->GetPageListDM($list_len)); |
|
在下面添加代码:
1 |
else if ($tagname== "itemcount" ) |
3 |
$list_len = trim($ctag->GetAtt( "listsize" )); |
8 |
$this->dtp->Assign($tagid,$this->GetItemsCountDM($list_len)); |
|
第二步,查找代码(大概在第925行):
在其上面添加下面的这段代码:
04 |
function GetItemsCountDM($list_len) |
07 |
$pagenow = ($this->PageNo-1) * 10 + 1; |
08 |
$pagenows = $this->PageNo*10; //当结果超过限制时,重设结果页数 |
09 |
if ($this->TotalResult > $this->SearchMaxRc) |
11 |
$totalpage = ceil($this->SearchMaxRc/$this->PageSize); |
13 |
$plist .= $this->TotalResult; |
|
第三步,在搜索结果页模板里要显示结果条数的地方通过如下标签调用:
1 |
{dede:itemcount listsize= '4' /} |
|
这样就可以实现搜索结果页的搜索结果数量的单独调用了。