Due to DEDEV5, SQL injection and security checks have been intensified, resulting in the inability to query SQL for some of the normal subqueries.
The following code is used to resolve the total number of articles in the current column and all sub-columns under the current column, added to/include/common.func.php
Or
/include/extend.func.php, and then calls Gettotalarcbytid (1) in the template.
/* * Returns the number of articles that match the record * @description Dede does not allow subqueries to solve the problem of the column under the article statistics * @param $level for the true query all sub-categories * */function Gettotalarcbytid ($tid, $level =true) {global $dsql; $level ==true && $tid = Getsontypeid ($tid); $sql = "SELECT count (ID) as total from ' dede_archives ' where typeid in ($tid)"; $result = $dsql->getone ($sql); return $result [' Total ']; }/* * Recursive access to eligible sub-columns * @param $tid Column ID * @return String * */function Getsontypeid ($tid) {global $dsql; $dsql->setquer Y ("Select id from ' Dede_arctype ' where Reid in ($tid) and Ishidden <> Span style= "color: #000000;" >1 ORDER by Sortrank "); $dsql->execute ($tid); $typeid = "; while ($row = $dsql->getobject ($tid)) {$typeid. = "{$row->id},"; $typeid. = Getsontypeid ($row->id);} return Trim ($typeid, ', '); }
Call Method:
The methods that are called in the template are generally:
{Dede:field.typeid function= "Gettotalarcbytid (@me)"/}
Or
[Field:typeid function= "Gettotalarcbytid (@me)"/]
Dedecms get the number of articles in the current column and all sub-columns