首先打开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;
添加完毕保存后再打开/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'
);
打开/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>
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!