当前位置:网站首页>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 !
边栏推荐
- phpcms小程序插件api接口升级到4.3(新增批量获取接口、搜索接口等)
- [Matlab GUI] key ID lookup table in keyboard callback
- 力扣399【除法求值】【并查集】
- docker安装redis
- Particles and sound effect system in games104 music 12 game engine
- yolov5进阶之零环境快速创建及测试
- Yolov5 advanced III training environment
- Slider verification - personal test (JD)
- Yolov5进阶之一摄像头实时采集识别
- Nebula diagram_ Object detection and measurement_ nanyangjx
猜你喜欢

Fast construction of neural network

Notes on setting qccheckbox style

Isinstance() function usage

Yolov5 advanced 5 GPU environment setup

yolov5进阶之零环境快速创建及测试

Uniapp uses uparse to parse the content of the background rich text editor and modify the uparse style

phpcms小程序插件api接口升级到4.3(新增批量获取接口、搜索接口等)

PD fast magnetization mobile power supply scheme

深度学习论文阅读目标检测篇(七)中文版:YOLOv4《Optimal Speed and Accuracy of Object Detection》

百度小程序富文本解析工具bdParse
随机推荐
XSS 跨站脚本攻击
关于小程序tabbar不支持传参的处理办法
HDU - 6225 Little Boxes(__int128的使用)
Line detection_ nanyangjx
SRv6----IS-IS扩展
Structure diagram of target detection network
PD快充磁吸移动电源方案
Trimming_ nanyangjx
Leetcode: array fast and slow pointer method
Autoregressive model of Lantern Festival
Ultrasonic image segmentation
phpcms v9手机访问电脑站一对一跳转对应手机站页面插件
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (I)
小程序首页加载之前加载其他相关资源或配置(小程序的promise应用)
How to set the shelves and windows, and what to pay attention to in the optimization process
Selenium 搭建 Cookies池 绕过验证反爬登录
uniapp用uParse实现解析后台的富文本编辑器的内容及修改uParse样式
【微积分】拉格朗日乘子法
1.25 suggestions and design of machine learning
Object extraction_ nanyangjx