本文介绍了pbootcms后台列表增加阅读量和点赞量的方法,PbootCMS后台默认不带文章内容阅读量及点赞量的修改功能,为了方便“增加”浏览,可以通过修改代码实现。一起来看看吧。
效果如图:
pbootcms,pbootcms点赞量,pbootcms阅读量
操作方法:
1)打开apps/admin/controller/content/ContentController.php文件
找到
查看源码
// 文章修改
public function mod()
{
if (! ! $submit = post(‘submit’)) {
switch ($submit) {
下面添加
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;
添加完毕保存后
2)再打开/apps/admin/model/content/ContentModel.php文件
在每一个如下代码中添加’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’
);
3)打开/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>
这样就可以了~