Dedecms get the number of articles in the current column and all sub-columns

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.