DEDE调用当前栏目文章数量,DEDE列表,DEDE首页都可以调用当前栏目的文档总数,例图如下:

DEDE调用当前栏目文章数量

调用方法如下:打开include/common.func.php,在这个php文件的最底部,在?>的前面添加如下代码

/*
* 获取当前栏目文档的数量
* */

    function GetTotalArc($tid){ 
      global $dsql; 
      $sql = GetSonIds($tid); 
      $row = $dsql->GetOne("Select count(id) as dd From dede_archives where typeid 
    in({$sql})"); 
      return $row['dd']; 
    }   
    //统计当前栏目信息数     
    function dynamic_num($current_id){ 
    global $dsql; 
    //读取当前栏目的子ID     
    $sql = "SELECT id FROM `dede_arctype` WHERE id='$current_id' || 
    topid='$current_id'"; 
    $dsql->SetQuery($sql); 
    $dsql->Execute(); 
    while($row = $dsql->GetArray()){ 
    $arr[]=$row[id]; 
    }     
    foreach($arr as $key=>$value){ 
       $type .= $value . ','; 
    }     
    $ty= "".$type."0"; 
    //echo $ty; 
    $t_num = $dsql->GetOne("select count(*) as num from `dede_archives` where typeid 
    in($ty)"); 
    //echo $t_num[num]; 
    if(is_array($t_num)){ 
      return " ".$t_num[num]." "; 
      
      }else{     
      return "0" ;     
    }     
    }   
    $sql = "SELECT id FROM `dede_arctype` WHERE id='$current_id' || 
    topid='$current_id'"; 
    $dsql->SetQuery($sql); 
    $dsql->Execute(); 
    while($row = $dsql->GetArray()){ 
    $arr[]=$row[id]; 
    }     
    foreach($arr as $key=>$value){ 
       $type .= $value . ','; 
    }     
    $ty= "".$type."0"; 
    //echo $ty; 
    $t_num = $dsql->GetOne("select count(*) as num from `dede_archives` where typeid 
    in($ty)"); 
    //echo $t_num[num]; 
    if(is_array($t_num)){ 
      return " ".$t_num[num]." "; 
      
      }else{     
      return "0" ;     
    }     
    }


加好以上代码之后保存这个php文件,然后再在列表或者首页模板中用以下标签进行调用:

{dede:type}[field:id function=”dynamic_num(@me)” /]{/dede:type}

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。