欢迎访问热站网,开始您的建站营销之旅!!

您现在的位置: 首页>>pbootcms教程

pbootcms后台内容列表增加阅读量和点赞量自定义修改

来源:热站网 发布时间:2026-04-08 19:13:54 热度:0 ℃


PbootCMS后台默认不带文章内容阅读量及点赞量的修改功能,为了方便“增加”浏览,可以通过修改代码实现。

1-22110ZU521S5.jpg

    首先打开apps/admin/controller/content/ContentController.php文件

    找到

1      // 文章修改    
2    public function mod()    
3    {    
4     if (! ! $submit = post('submit')) {    
5     switch ($submit) {

在下面添加代码

01      case 'pbootnet': // 修改文章访问量    
02      $listall = post('listall');    
03      if ($listall) {    
04      $visits = post('visits');    
05      foreach ($listall as $key => $value) {    
06      if ($visits[$key] === '' || ! is_numeric($visits[$key]))    
07       $visits[$key] = visits;    
08      $this->model->modContent($value, "visits=" . $visits[$key]);    
09       }    
10    $likes = post('likes');    
11     foreach ($listall as $key => $value) {    
12     if ($likes[$key] === '' || ! is_numeric($likes[$key]))    
13     $likes[$key] = likes;    
14     $this->model->modContent($value, "likes=" . $likes[$key]);    
15      }        
16    $this->log('修改内容访问量成功!');    
17      success('修改成功!', - 1);    
18    } else {    
19    alert_back('修改失败,无任何内容!');    
20      }    
21      break;


添加完毕保存后

再打开/apps/admin/model/content/ContentModel.php文件

在每一个如下代码中添加'a.likes',

01    $field = array(    
02    
03                'a.id',    
04    
05                'b.name as sortname',    
06    
07                'a.scode',    
08    
09                'c.name as subsortname',    
10    
11                'a.subscode',    
12    
13                'a.title',    
14    
15                'a.subtitle',    
16    
17                'a.date',    
18    
19                'a.sorting',    
20    
21                'a.status',    
22    
23                'a.istop',    
24    
25                'a.isrecommend',    
26    
27                'a.isheadline',    
28    
29                'a.visits',    
30    
31                'a.likes',    
32    
33                'a.ico',    
34    
35                'a.pics',    
36    
37                'a.filename',    
38    
39                'a.outlink',    
40    
41                'd.urlname',    
42    
43                'b.filename as sortfilename'    
44    
45            );

打开/apps/admin/view/default/content/content.html文件

找到

 <th>访问量</th>

在它下添加

<th>点赞量</th>

再找到

<td>value->visits</td>

改成

<td class="table-input"><input type="text" lay-ignore class="layui-input" name="visits[]" value="[value->visits]"></td>    
<td class="table-input"><input type="text" lay-ignore class="layui-input" name="likes[]" value="[value->likes]"></td>

在找到

<button type="submit" name="submit" value="sorting" class="layui-btn layui-btn-sm">保存排序</button>

在它面添加 

<button type="submit" name="submit" value="pbootnet" class="layui-btn layui-btn-sm">保存阅读点赞量</button>





文章搜集与网络,如有侵权请联系本站,转载请说明出处:https://www.rezhanwang.com/pbootcms/3832.html

责任编辑:热站网
 
QQ在线咨询