Home >CMS Tutorial >DEDECMS >How does Dedecms call the number of articles in the current column?
How does DreamWeaver dedecms call the number of articles in the current column?
Dreamweaver dedecms calls the current column article number method
When making a template, it is often necessary to add the number of articles in this column to each column. Let me share with you the implementation method. This method is suitable for 5.6, 5.7, 5.7sp1 and other untested
Recommended learning: dedecms tutorial
Steps/Method
Modify the include/common.func.php file and add the following code at the end:
//统计栏目文章数 function GetTotalArc($tid){ global $dsql; $sql = GetSonIds($tid); $row = $dsql->GetOne("Select count(id) as dd From zmb_archives where typeid in({$sql})"); return $row['dd']; } //统计当前栏目信息数 function dynamic_num($current_id){ global $dsql; //读取当前栏目的子ID $sql = "SELECT id FROM zmb_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 zmb_archives where typeid in($ty)"); //echo $t_num[num]; if(is_array($t_num)){ return " ".$t_num[num]." "; }else{ return "0" ; } }
Calling code in the template:
(This class has {dede: type}[field:id function="dynamic_num(@me)" /]{/dede:type}
documents)
and
[field:id runphp='yes'] @me = GetTotalArc(@me);[/field:id]
For example:
{dede:field name='typename'/}</b>(该类拥有{dede:type}[field:id function="dynamic_num(@me)" /]{/dede:type}个文档) {dede:channel type='son' } <li><a href='[field:typelink/]'>[field:typename/]</a>(<span>[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]</span>)</li> {/dede:channel}
The above is the detailed content of How does Dedecms call the number of articles in the current column?. For more information, please follow other related articles on the PHP Chinese website!