PbootCMS后臺默認不帶文章內容閱讀量及點贊量的修改功能,為了方便“增加”瀏覽,可以通過修改代碼實現。
首先打開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文件
在它下添加
再找到
改成
<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>
|