Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to access phpcms's recently updated articles

Shulou Source: shulou.com Published: 2022-06-02 07:25:14 10月02日 Update

Today, I will talk to you about how to access the articles recently updated by phpcms. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something from this article.

How does phpcms access the most recently updated articles?

Phpcms v9 calls the latest articles on the site (update everything recently)

The first step is to modify phpcms\ modules\ content\ classes content_tag.class.php to add to the last}

Public function newcontent ($data) {$num = intval ($data ['limit'])? Intval ($data ['limit']):' 20ranking / setting sort switch ($data ['order']) {case' 1':$order = '`id`ASC'; break;case '2':$order =' `id`DESC'; break;case '3':$order =' `inputtime`ASC'; break;case '4':$order =' `inputtime`DESC'; break;case '5':$order =' `updatetime` ASC'; break;case '6':$order =' `updatetime`DESC'; break;default:$order = '`id`DESC' } if ($data ['catid']) {$catids = explode (',', $data ['catid']); foreach ($catids as $catid) {$catid = intval ($catid); if (empty ($catid)) continue;$this- > set_modelid ($catid); $where = $this- > category [$catid] [' child']? `catid`IN ('. $this- > category [$catid] ['arrchildid'].')': "`catid` = $catid"; $datas = $this- > db- > select ($where,'*', $num, $num) $data [$catid] ['data'] = $datas;// record the number of articles $data [' num'] [] = count ($datas); $model_num++;}} else {$models = getcache ('model',' commons'); foreach ($models as $model) {$this- > db- > set_model ($model ['modelid']); $datas = $this- > db- > select ('','*', $num, $order); $data [$model ['modelid']] [' data'] = $datas / / record the number of articles this time $data ['num'] [] = count ($datas); $model_num++;}} if ($data) {/ / get the number of entries that should be intercepted by each model $num = ceil ($num/$model_num); / / the number of loops is used to find out the number of articles that are not satisfied and then average $w_num = $w_num_t ='' Foreach ($data ['num'] as $num_t) {if ($num_t < $num) {$w_num + = $num-$num_t;$w_num_t++;}} / / determine if there is anything that does not meet the average, then increase the average if ($w_num_t) {$num + = ceil ($w_num/ ($model_num-$w_num_t));} $datas = array (); foreach ($data as $r) {$rnsn ='' If (is_array ($r ['data']) foreach ($r [' data'] as $rystt) {$datas [] = $rattlesif (+ + $rattn = = $num) break;}} return $datas;} else {return false;}}

Step 2: template call

In fact, it is similar to the default article list call.

{pc:content action= "newcontent"}

Parameter description:

Catid: if you don't need to add it, just call the information of the specified column. For multiple columns, please use the English half-corner, interval.

Order: sort parameter value: 1-7 the specific meaning is easy to read in the code.

Num: the number of calls does not specify 20 calls by default

After reading the above, do you have any further understanding of how to access the recently updated articles from phpcms? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Article update content parameter quantity column sort optional almost code information full site half corner meaning multiple average average more latest article model Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno vpn NVidia Apple Shulou Tech Info