PbootCMS 后台内容列表增加阅读量和点赞量自定义修改
- 打开
apps/admin/controller/content/ContentController.php
文件,找到mod
函数,在switch
语句中添加代码:
case 'pbootnet': // 修改文章访问量 $listall = post('listall'); if ($listall) { $visits = post('visits'); foreach ($listall as $key => $value) { if ($visits[$key] === '' || !is_numeric($visits[$key])) { $visits[$key] = visits; } $this->model->modContent($value, "visits=" . $visits[$key]); } $likes = post('likes'); foreach ($listall as $key => $value) { if ($likes[$key] === '' || !is_numeric($likes[$key])) { $likes[$key] = likes; } $this->model->modContent($value, "likes=" . $likes[$key]); } $this->log('修改内容访问量成功!'); success('修改成功!', -1); } else { alert_back('修改失败,无任何内容!'); } break;
- 打开
apps/admin/model/content/ContentModel.php
文件,在$field
数组中添加'a.likes'
:
$field = array( 'a.id', 'b.name as sortname', 'a.scode', 'c.name as subsortname', 'a.subscode', 'a.title', 'a.subtitle', 'a.date', 'a.sorting', 'a.status', 'a.istop', 'a.isrecommend', 'a.isheadline', 'a.visits', 'a.likes', 'a.ico', 'a.pics', 'a.filename', 'a.outlink', 'd.urlname', 'b.filename as sortfilename' );
- 打开
apps/admin/view/default/content/content.html
文件,找到<th>访问量</th>
,在其下添加<th>点赞量</th>
。 - 再找到
<td>value->visits</td>
,改成:
<button type="submit" name="submit" value="pbootnet" class="layui-btn layui-btn-sm">保存阅读点赞量</button>
- 在
<button type="submit" name="submit" value="sorting" class="layui-btn layui-btn-sm">保存排序</button>
前添加:
if (!$ico && preg_match('/<img\s+.*?src=\s?[\''|"](.*?(\.gif|\.jpg|\.png|\.jpeg))[\''"].*?[\/]?>/i', decode_string($content), $srcs) && isset($srcs[1])) { $ico = $srcs[1]; }