search
HomeCMS TutorialDEDECMSHow does Dedecms call the number of articles in the current column?

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=&#39;typename&#39;/}</b>(该类拥有{dede:type}[field:id 
function="dynamic_num(@me)" /]{/dede:type}个文档)
{dede:channel type=&#39;son&#39; } 
<li><a href=&#39;[field:typelink/]&#39;>[field:typename/]</a>(<span>[field:ID 
runphp=&#39;yes&#39;] @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!

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

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),

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)