迅睿開源框架是一款PHP8高性能·簡單易用的PHP開源開發(fā)框架, 基于MIT開源許可協(xié)議發(fā)布,不限制商業(yè)使用,以多端互聯(lián)為設(shè)計理念, 支持的微信公眾號、小程序、APP客戶端、移動端網(wǎng)站、PC網(wǎng)站等多終端式管理系統(tǒng)。
業(yè)務(wù)經(jīng)理
微信掃描以上二維碼
028-61286886
技術(shù)咨詢
{dr_show_hits($id)}
點擊量如果想實現(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ù)@小波工作室 這個怎么弄!
回復(fù)@王小五 代碼復(fù)制到config/custom.php里,然后調(diào)用點擊數(shù)那改成{convert(dr_show_hits($id))}
不過這個hits可能需要處理下
回復(fù)@芝麻通 {convert(dr_show_hits($id))} 這個在show.html調(diào)用的話 直接輸出了代碼呢? 沒有輸出結(jié)果
回復(fù)@游子2018 {convert($hits)}
不過這個不是動態(tài)增加了
回復(fù)@芝麻通 不過這個不能動態(tài)的調(diào)用的話 也不好用 這是一個很好的功能需求 如果訪問量過大的話。
我是這樣弄的,不能直接用{convert(dr_show_hits($id))},因為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ù)表……
為了訪問時候點擊率自動累加,這個還得保留,用display:none隱藏掉……
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ù)@小波工作室 這個怎么弄!
回復(fù)@王小五 代碼復(fù)制到config/custom.php里,然后調(diào)用點擊數(shù)那改成{convert(dr_show_hits($id))}
不過這個hits可能需要處理下
回復(fù)@芝麻通 {convert(dr_show_hits($id))} 這個在show.html調(diào)用的話 直接輸出了代碼呢? 沒有輸出結(jié)果
回復(fù)@游子2018 {convert($hits)}
不過這個不是動態(tài)增加了
回復(fù)@芝麻通 不過這個不能動態(tài)的調(diào)用的話 也不好用 這是一個很好的功能需求 如果訪問量過大的話。
我是這樣弄的,不能直接用{convert(dr_show_hits($id))},因為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ù)表……
為了訪問時候點擊率自動累加,這個還得保留,用display:none隱藏掉……