DEDE的搜索结果数量都集成在了列表分页标签里,并没有使用单独的函数来提供这个结果数量,因此对有单独调用搜索结果数量的用户来说,就有使用问题,这里提供二次开发的方法。
非常简单只要修改几个地方就行了:
第一步,打开/include/arc.searchview.class.php文件,查找代码(大概在第525行):
|
|
|
1 |
else if($tagname=="pagelist") |
|
2 |
{ |
|
3 |
$list_len = trim($ctag->GetAtt("listsize")); |
|
4 |
if($list_len=="") |
|
5 |
{ |
|
6 |
$list_len = 3; |
|
7 |
} |
|
8 |
$this->dtp->Assign($tagid,$this->GetPageListDM($list_len)); |
|
9 |
} |
在下面添加代码:
|
|
|
1 |
else if($tagname=="itemcount") |
|
2 |
{ |
|
3 |
$list_len = trim($ctag->GetAtt("listsize")); |
|
4 |
if($list_len=="") |
|
5 |
{ |
|
6 |
$list_len = 3; |
|
7 |
} |
|
8 |
$this->dtp->Assign($tagid,$this->GetItemsCountDM($list_len)); |
|
9 |
} |
第二步,查找代码(大概在第925行):
/** * 获得当前的页面文件的url * * @access public * @return string */
在其上面添加下面的这段代码:
|
|
|
01 |
function GetItemsCountDM($list_len) |
|
02 |
{ |
|
03 |
global $oldkeyword; |
|
04 |
$pagenow = ($this->PageNo-1) * 10 + 1; |
|
05 |
$pagenows = $this->PageNo*10; //当结果超过限制时,重设结果页数 |
|
06 |
if($this->TotalResult > $this->SearchMaxRc) |
|
07 |
{ |
|
08 |
$totalpage = ceil($this->SearchMaxRc/$this->PageSize); |
|
09 |
} |
|
10 |
$plist .= $this->TotalResult; |
|
11 |
return $plist; |
|
12 |
} |
第三步,在搜索结果页模板里要显示结果条数的地方通过如下标签调用:
{dede:itemcount listsize='4'/}
这样就可以实现搜索结果页的搜索结果数量的单独调用了。