Dream weaving dedecms calls the method of the number of articles in the current column
This article is to share with you about the method of dream weaving dedecms calling the number of articles in the current column. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
How does dream weaving dedecms call the number of articles in the current column?
Dream weaving dedecms calls the number of articles in the current column
When making a template, it is often necessary to add the number of articles for each column. Share with you the implementation method, this method is suitable for 5.6and 5.7, 5.7sp1 other untested
Steps / methods
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'];} / Statistics current column information function dynamic_num ($current_id) {global $dsql; / / read the current column's sub-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 $tnum [num]; if (is_array ($t_num)) {return". $tnum. ";} else {return" 0 ";}}
The 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='typename'/} (this class has {dede:type} [field:id function= "dynamic_num (@ me)" /] {/ dede:type} documents) {dede:channel type='son'} [field:typename/] ([field:ID runphp='yes'] @ me= GetTotalArc (@ me); [/ field:ID]) {/ dede:channel} Thank you for reading! About weaving dream dedecms calls the current column article number method to share here, I hope the above content can have some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.