search
HomeCMS TutorialDEDECMSHow does DEDECMS get the number of articles in the current column and all sub-columns?

How does DEDECMS get the number of articles in the current column and all sub-columns?

DEDECMS How to get the number of articles in the current column and all sub-columns?

The following code is used to query the total number of articles in the current column and all sub-columns under the current column, and is added to /include/common.func.php

or /include/extend. func.php, and then call getTotalArcByTid(1) in the template.

Recommended learning: Dream Weaver cms

The code is as follows:

/* 
* 返回符合记录的文章数量 
* @description DEDE不允许执行子查询,解决栏目下文章统计的问题 
* @param $level 为真时查询所有子类目 
* */ 
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']; 
} 
/* 
* 递归获取符合条件的子栏目 
* @param $tid 栏目ID 
* @return string 
* */ 
function GetSonTypeID($tid) 
{ 
global $dsql; 
$dsql->SetQuery("Select id From `dede_arctype` where reid in($tid) And ishidden<>1 order by sortrank"); 
$dsql->Execute($tid); 
$typeid = &#39;&#39;; 
while($row=$dsql->GetObject($tid)) 
{ 
$typeid .= "{$row->id},"; 
$typeid .= GetSonTypeID($row->id); 
} 
return trim($typeid,&#39;,&#39;); 
}

Calling method:

The method called in the template is generally :

{dede:field.typeid function="getTotalArcByTid(@me)"/}

or

[field:typeid function="getTotalArcByTid(@me)"/]

The above is the detailed content of How does DEDECMS get the number of articles in the current column and all sub-columns?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.