Verycms call the hottest article of the month

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

As one of the fans of Verycms, how can I not make a little contribution to express my loyalty?

Verycms is my first use of a CMS system, his template function is really very simple and practical, especially his template can parse PHP script, which can add some complex calls.

This time I'm going to teach you how to call the hottest hits of the day and the hottest clicks of the month, actually the principle is very simple, find the time period of the article, and then click on the number of descending sort. Now the decomposition of teaching, step-by-step:

First, the implementation of the number of clicks sorted

This is very simple, find the statement to get an array of articles, such as this sentence: $array = $cms:: Thread ("num:10;mid:1;");

To achieve the order by number of clicks, as long as the query conditions can be increased, that is, to add an order in SQL, how to achieve it? Modify the $array access mode to: $array = $cms:: Thread ("Num:10;mid:1;order:hits DESC;");

Second, the realization by the day clicks the number sorts

With the first step of the foundation, to achieve by the day to sort the number of clicks, just solve another problem: how to filter the article for the release of the article? The same day, like today is 2008-07-22 00:00:00, we want to get the time stamp of this time (what is the timestamp, this does not parse, You want to know about Google), we use PHP a function strtotime to achieve the purpose:

Strtotime (' 2008-07-22 00:00:00′); That's right, if that's the case today, but it's going to be miserable by tomorrow, so the positive solution should be this: strtotime (date ("y-m-d")); With this understanding, let's take a look at how $array gets the article, and the method is simple enough to look at the following statements:

  

$today = Strtotime (Date ("y-m-d"));

$array = $cms:: Thread ("num:10;mid:1;where:postdate> $today; order:hits DESC;");

Third, the implementation by the number of clicks sorted

With the second step of the idea, then the implementation of the number of clicks in order to change is very empty easy, learning is to find a way to get the month 1th zero 0 minutes 0 seconds of time stamp, I also no longer wordy, the code posted out to see you know:

  

$first _day_of_month = strtotime (Date ("Y-m-01″)")//There are 01 that means the first day of the month.

$array = $cms:: Thread ("num:10;mid:1;where:postdate> $first _day_of_month; order:hits DESC;");

I hope this article will be helpful to you who have just contacted Verycms.

Article Source Address: http://www.4studio.cn/blog/?p=293

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.