当前位置:网站首页>Phpcms V9 adds the reading amount field in the background, and the reading amount can be modified at will
Phpcms V9 adds the reading amount field in the background, and the reading amount can be modified at will
2022-06-26 09:03:00 【CMS applet plug-in [official]】
because phpcms The content table of is separate from the hits , Therefore, the official does not set a field to control the amount of reading in the background , Sometimes we need to customize the amount of reading , This requires simple secondary development .
(1) find phpcms\modules\content\templates The folder content_edit.tpl.php and content_add.tpl.php Two documents
content_edit.tpl.php Probably 80 That's ok , Find the following code :
- </tbody></table>
Add the following code before this line of code :
- <tr>
- <th width="80"> Reading volume </th>
- <td><input type='text' name='info[views]' id='views' value='<?php echo $views;?>' size='3' class='input-text'> ( Default random generation )</td>
- </tr>
Again content_add.tpl.php Probably 82 That's ok , Find the following code :
</tbody></table> Add the same code before that
- <tr>
- <th width="80"> Reading volume </th>
- <td><input type='text' name='info[views]' id='views' value='<?php echo $views;?>' size='3' class='input-text'> ( Default random generation )</td>
- </tr>
(2) find phpcms\model\content_model.class.php Find out about 107 That's ok :
- // Add Statistics
- $this->hits_db = pc_base::load_model('hits_model');
- $hitsid = 'c-'.$modelid.'-'.$id;
- $this->hits_db->insert(array('hitsid'=>$hitsid,'catid'=>$systeminfo['catid'],'updatetime'=>SYS_TIME));
Change to :
- // Add Statistics
- $views = $data['views'];
- $this->hits_db = pc_base::load_model('hits_model');
- $hitsid = 'c-'.$modelid.'-'.$id;
- $this->hits_db->insert(array('hitsid'=>$hitsid,'catid'=>$systeminfo['catid'],'views'=>$views,'updatetime'=>SYS_TIME));
then 301 Line find the code :
- // call update
Add code before that :
- // Add Statistics
- $views = $data['views'];
- $this->hits_db = pc_base::load_model('hits_model');
- $hitsid = 'c-'.$this->modelid.'-'.$id;
- $this->hits_db->update(array('views' => $views),array('hitsid' => $hitsid));
(3) find \phpcms\modules\content\content.php file
Probably 163 Line find the code :
- param::set_cookie('module', 'content');
Add a new code to generate random hits :
- $views = rand(10,999);/* Generate random hits */
Then find the code, which is about 250 That's ok :
- $forminfos = $content_form->get($data);
- $formValidator = $content_form->formValidator;
Add code after this :
- /* Load Click */
- $hitsid = "c-".$modelid."-".$id;
- $db_hits = pc_base::load_model('hits_model');// introduce hits
- $view = $db_hits ->get_one(array('hitsid' => $hitsid),'views');
- $views = $view['views'];
After the addition , Update cache , You can try adding or modifying articles , See if you can change the reading amount at will !
边栏推荐
- ROS learning notes (6) -- function package encapsulated into Library and called
- Live review | smardaten lihongfei interprets the Research Report on China's low / no code industry: the wind direction has changed
- ImportError: ERROR: recursion is detected during loading of “cv2“ binary extensions. Check OpenCV in
- Mongodb分片环境搭建和验证(redis期末大作业)
- Selenium builds cookies pool to bypass authentication and anti crawl login
- 爬虫 对 Get/Post 请求时遇到编码问题的解决方案
- 什么是乐观锁,什么是悲观锁
- 【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(一)
- 【IVI】15.1.2 系统稳定性优化篇(LMKD Ⅱ)PSI 压力失速信息
- Machine learning (Part 2)
猜你喜欢

Reverse crawling verification code identification login (OCR character recognition)

【程序的编译和预处理】

Solution to the encoding problem encountered by the crawler when requesting get/post

Principle of playing card image segmentation

phpcms v9后台文章列表增加一键推送到百度功能

Games104 Lecture 12 游戏引擎中的粒子和声效系统

Yolov5 advanced zero environment rapid creation and testing

基于SSM的电脑商城

百度小程序富文本解析工具bdParse

Detailed explanation of traditional image segmentation methods
随机推荐
Code de mise en œuvre de l'intercepteur et du filtre
Reverse crawling verification code identification login (OCR character recognition)
Yolov5进阶之二安装labelImg
Solution to the encoding problem encountered by the crawler when requesting get/post
1.17 daily improvement of winter vacation learning (frequency school and Bayesian school) and maximum likelihood estimation
隐藏式列表菜单以及窗口转换在Selenium 中的应用
Line detection_ nanyangjx
Tensor
ROS learning notes (5) -- Exploration of customized messages
Section IV HQL execution process
实践是成为网工最快的方法,网络工程师实战项目整理
Fast construction of neural network
Some commands for remote work
Selenium 搭建 Cookies池 绕过验证反爬登录
1.20 study univariate linear regression
Regular Expression 正则表达式
2021 software university ranking crawler program
XSS cross site scripting attack
唯品会工作实践 : Json的deserialization应用
phpcms手机站模块实现自定义伪静态设置