迅睿CMS框架是一款PHP8高性能·簡單易用的CMS開源開發(fā)框架,基于MIT開源許可協(xié)議發(fā)布,免費(fèi)且不限制商業(yè)使用,是免費(fèi)開源的產(chǎn)品,以萬端互聯(lián)為設(shè)計(jì)理念,支持的微信公眾號(hào)、小程序、APP客戶端、移動(dòng)端網(wǎng)站、PC網(wǎng)站等多終端式管理系統(tǒng)。
聯(lián)系官方銷售客服
1835022288
028-61286886
{dr_show_hits($id)}
點(diǎn)擊量如果想實(shí)現(xiàn) (見下圖)
1000以上的閱讀量可以轉(zhuǎn)化為1k
例如 1600 轉(zhuǎn)換為1.6k
或者 16600 轉(zhuǎn)換為 1.66w
怎么寫呢
function convert($num) { if ($num >= 100000) { $num = round($num / 10000) .'W+'; } else if ($num >= 10000) { $num = round($num / 10000, 1) .'W+'; } else if($num >= 1000) { $num = round($num / 1000, 1) . 'K+'; } return $num; }
回復(fù)@小波工作室
回復(fù)@小波工作室 這個(gè)怎么弄!
回復(fù)@王小五 代碼復(fù)制到config/custom.php里,然后調(diào)用點(diǎn)擊數(shù)那改成{convert(dr_show_hits($id))}
不過這個(gè)hits可能需要處理下
回復(fù)@芝麻通 {convert(dr_show_hits($id))} 這個(gè)在show.html調(diào)用的話 直接輸出了代碼呢? 沒有輸出結(jié)果
回復(fù)@游子2018 {convert($hits)}
不過這個(gè)不是動(dòng)態(tài)增加了
回復(fù)@芝麻通 不過這個(gè)不能動(dòng)態(tài)的調(diào)用的話 也不好用 這是一個(gè)很好的功能需求 如果訪問量過大的話。
我是這樣弄的,不能直接用{convert(dr_show_hits($id))},因?yàn)?span style="color: rgb(51, 51, 51); font-family: Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">dr_show_hits($id)是ajax加載的
將{convert(dr_show_hits($id))}變?yōu)?span style="font-family: Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); color: rgb(192, 0, 0);"> {convert($id)}
然后去config/custom.php里加上如下代碼
function convert($value) { $rt = \Phpcmf\Service::M()->db->table("1_news")->select("hits")->where('id', $value)->get(); $rows = $rt->getResultArray(); $num = $rows[0]['hits']; if ($num >= 100000) { $num = round($num / 10000) .'W+'; } else if ($num >= 10000) { $num = round($num / 10000, 1) .'W+'; } else if($num >= 1000) { $num = round($num / 1000, 1) . 'K+'; } return $num; }
其中1_news修改為數(shù)你的數(shù)據(jù)表……
為了訪問時(shí)候點(diǎn)擊率自動(dòng)累加,這個(gè)還得保留,用display:none隱藏掉……
回復(fù)@小波工作室
回復(fù)@小波工作室 這個(gè)怎么弄!
回復(fù)@王小五 代碼復(fù)制到config/custom.php里,然后調(diào)用點(diǎn)擊數(shù)那改成{convert(dr_show_hits($id))}
不過這個(gè)hits可能需要處理下
回復(fù)@芝麻通 {convert(dr_show_hits($id))} 這個(gè)在show.html調(diào)用的話 直接輸出了代碼呢? 沒有輸出結(jié)果
回復(fù)@游子2018 {convert($hits)}
不過這個(gè)不是動(dòng)態(tài)增加了
回復(fù)@芝麻通 不過這個(gè)不能動(dòng)態(tài)的調(diào)用的話 也不好用 這是一個(gè)很好的功能需求 如果訪問量過大的話。
我是這樣弄的,不能直接用{convert(dr_show_hits($id))},因?yàn)?span style="color: rgb(51, 51, 51); font-family: Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">dr_show_hits($id)是ajax加載的
將{convert(dr_show_hits($id))}變?yōu)?span style="font-family: Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); color: rgb(192, 0, 0);"> {convert($id)}
然后去config/custom.php里加上如下代碼
其中1_news修改為數(shù)你的數(shù)據(jù)表……
為了訪問時(shí)候點(diǎn)擊率自動(dòng)累加,這個(gè)還得保留,用display:none隱藏掉……