PbootCMS后台默认不带文章内容阅读量及点赞量的修改功能,为了方便“增加”浏览,可以通过修改代码实现。
首先打开apps/admin/controller/content/ContentController.php文件
找到
4 |
if (! ! $submit = post( 'submit' )) { |
|
在下面添加代码
01 |
case 'pbootnet' : // 修改文章访问量 |
02 |
$listall = post( '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]); |
10 |
$likes = post( 'likes' ); |
11 |
foreach ($listall as $key => $value) { |
12 |
if ($likes[$key] === '' || ! is_numeric($likes[$key])) |
14 |
$this->model->modContent($value, "likes=" . $likes[$key]); |
16 |
$this->log( '修改内容访问量成功!' ); |
17 |
success( '修改成功!' , - 1); |
19 |
alert_back( '修改失败,无任何内容!' ); |
|
添加完毕保存后
再打开/apps/admin/model/content/ContentModel.php文件
在每一个如下代码中添加’a.likes’,
09 |
'c.name as subsortname' , |
43 |
'b.filename as sortfilename' |
|
打开/apps/admin/view/default/content/content.html文件
在它下添加
再找到
改成
1 |
<td class= "table-input" ><input type = "text" lay-ignore class= "layui-input" name= "visits[]" value= "[value->visits]" ></td> |
2 |
<td class= "table-input" ><input type = "text" lay-ignore class= "layui-input" name= "likes[]" value= "[value->likes]" ></td> |
|
在找到
1 |
<button type = "submit" name= "submit" value= "sorting" class= "layui-btn layui-btn-sm" >保存排序</button> |
|
在它面添加
1 |
<button type = "submit" name= "submit" value= "pbootnet" class= "layui-btn layui-btn-sm" >保存阅读点赞量</button> |
|