Dedecms useful statistics SQL statement Tag Collection
Source: Internet
Author: User
In the past two days, I suddenly saw many posts on the forum asking for Statistics Code. here I am sending several frequently-used DEDE statistics SQL labels. if you have any other requirements, please follow the instructions in the post, continue to add ...... In addition, I hope that you will search for the Forum first. maybe you can find the answer to your question in your previous post ~~ · Pay attention to dede_archi. in the past two days, I suddenly saw many posts on the forum asking for statistics using code. Here are several commonly used DEDE statistics SQL labels. if there are other requirements, please follow the instructions in the post to continue adding ......
In addition, I hope that you will search for the Forum first. maybe you can find the answer to your question in your previous post ~~
· Note that the dede_archives prefix is the default one. Please change dede to your database prefix. a total of articles: **
{Dede: SQL = "select count (ID) as c from dede_archives wherechannel = 1"} · a total of articles: [field: c/] {/dede: SQL}
· A total of Atlas: **
{Dede: SQL = "select count (ID) as c from dede_archives wherechannel = 2"} · total Gallery: [field: c/] {/dede: SQL}
· A total of software: **
{Dede: SQL = "select count (ID) as c from dede_archives wherechannel = 3"} · total software: [field: c/] {/dede: SQL}
· Comments: **
{Dede: SQL = "select count (ID) as c fromde_feedback"}. comments: [field: c/] {/dede: SQL}
· Total members: ** name
{Dede: SQL = "select count (ID) as c from dedede_member"}. Common member: [field: c/] name {/dede: SQL}
· Article reading: ** number of people
{Dede: SQL = "select sum (click) as c fromde_archives"} reading: [field: c/] count {/dede: SQL}
· Updated today: **
{Dede: SQL = "SELECT count (ID) AS c FROM dede_archives WHEREpubdate> UNIX_TIMESTAMP (CURDATE ()"} updated today: [field: c/] {/dede: SQL}
· Count the number of articles in a specified column and all subordinate branch columns
1. modify the include/inc_functions.php file and add the following function: functionGetTotalArc ($ tid ){
$ Dsql = new DedeSql (false );
$ SQL = TypeGetSunID ($ tid, $ dsql );
$ Row = $ dsql-> GetOne ("Select count (ID) as dd From dede_archiveswhere {$ SQL }");
Return $ row ['DD'];
} 2. call the method. Insert the following code on the template page to be modified (3 of the code is the column ID, which can be modified based on your actual situation)
{Dede: field function = 'gettotalarc (3:
If you call this method on the topic template page, you can use this method to count the number of articles in the current topic.
{Dede: field name = 'id' function = 'gettotalarc (@ me )'/}
· Column article statistics function
Use dedecms's runphp interface to write a function. use the channel tag's ID variable or.
Function.
Function GetChannelArticleNum ($ id ){
If (! $ Id |! Is_numeric ($ id) return 0;
$ Dsql = new DedeSql ();
Require_once (dirname (_ FILE _). "/inc_channel_unit_functions.php ");
$ SQL = TypeGetSunID ($ id, $ dsql );
$ Dsql-> SetQuery ("Select count (*) as c From dede_archives where {$ SQL }");
$ Row = $ dsql-> GetOne ();
Return $ row ['c'];
}
Put this function into inc_functions.php to call the method.
{Dede: channel type = 'top' row = '8'} | [field: typename/] ([field: IDrunphp = 'yes'] @ me = GetChannelArticleNum (@ me); [/field: ID]) {/dede: channel}
For the effect, see the home page menu of this site.
Change | [field: typename/] ([field: ID runphp = 'yes'] @ me = GetChannelArticleNum (@ me); [/field: ID]) for more forms.
If this method does not work, open inc_typelink.php (in dedecmsv3.1, refer to version 4.x)
Find
If ($ row = $ this-> dsql-> GetArray ())
{
Add a $ row ['id'] = $ row ['id'] to the style of the current topic in // processing the same level column;
This is a strange problem in dedecms. [Field: ID/] often does not get a value, and sometimes it is possible, but with $ row ['id'] = $ row ['id']; then you can use [field: ID/]. it may be that $ row ['id'] is used as a constant without quotation marks somewhere ......
· Added the column article statistics function
Method 1:
1. modify the include/inc_arcpart_view.php file.
Find the function ParseTemplet () function
To:
Function ParseTemplet ()
{
If (! Is_array ($ this-> dtp-> CTags) return "";
Foreach ($ this-> dtp-> CTags as $ tagid => $ ctag)
{
$ Tagname = $ ctag-> GetName ();
// Count the number of articles in the countclass column
If ($ tagname = "countclass "){
$ Tid = $ ctag-> GetAtt ("typeid ");
$ Row = $ this-> dsql-> GetOne ("Select count (ID) as dd fromde_archives where typeid = '$ tid' and arcrank <>-1 ");
$ This-> dtp-> Assign ($ tagid, $ row ['DD']);
}
2. call the method on the webpage
{Dede: countclass typeid = topic ID /}
For example:
{Dede: countclass typeid = '2'/} method 2 (provided by the forehand 339709 ):
1. modify the include/inc_functions.php file and add the following functions:
Function GetTotalArc ($ tid ){
$ Dsql = new DedeSql (false );
$ Row = $ dsql-> GetOne ("Select count (ID) as dd From dede_archiveswhere typeid = '$ tid '");
Return $ row ['DD'];
}
2. call method
[Field: id function = 'gettotalarc (@ me) '/]
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