Home CMS Tutorial DEDECMS How does dede count the number of column articles?

How does dede count the number of column articles?

Dec 07, 2019 am 10:54 AM
dede

How does dede count the number of column articles?

How does dede count the number of column articles?

dedeThe function of counting column articles is quite practical. This article introduces two implementation methods for you. You can choose freely according to your needs. Friends who like it can refer to it

Recommended learning: Dream Weaver cms

Method 1:

Involved files: include/common.func.php

Add the following code at the bottom of include/common.func.php, before ?>

The code is as follows:

function GetTotalArc($tid){ 
global $dsql; 
$sql = GetSonIds($tid); 
$row = $dsql->GetOne("Select count(id) as dd From dede_archives where typeid in({$sql})"); 
return $row['dd']; 
}
Copy after login

Calling method:

The code is as follows:

[field:ID function='GetTotalArc(@me)'/] 
或 
[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]
Copy after login

For example, add the following code to your homepage template:

{dede:type}[field:ID function='GetTotalArc(@me)'/] {/ dede:type}

Or add the following code after the column name:

The code is as follows:

{dede:type}[field:ID function='GetTotalArc(@me)'/] {/dede:type}
Copy after login

Method 2:

The first step: open the include/common.func.php file and add before the last ?>:

The code is as follows:

//统计栏目文章数 
function GetTotalArc($tid){ 
global $dsql; 
$sql = GetSonIds($tid); 
$row = $dsql->GetOne("Select count(id) as dd From dede_archives where typeid in({$sql})"); 
return $row['dd']; 
} 
//统计结束
Copy after login

The second step : You can use the following code on the template

The code is as follows:

{dede:channel type='top' typeid=''} 
<a href=&#39;[field:typelink /]&#39;>[field:typename/]</a> ([field:ID runphp=&#39;yes&#39;] @me = GetTotalArc(@me);[/field:ID])
{/dede:channel}
Copy after login

For example, the column name on the home page template ({dede:field name='typename'/})

Add the following code after:

The code is as follows:

{dede:type}[field:ID runphp=&#39;yes&#39;] @me = GetTotalArc(@me);[/field:ID]{/dede:type}
Copy after login

The above is the detailed content of How does dede count the number of column articles?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)