本文介紹了pbootcms後台列表增加閱讀量和(hé)點贊量的方法,PbootCMS後台默認不帶文章內(nèi)容閱讀量及點贊量的修改功能,為(wèi)了方便“增加”浏覽,可(kě)以通(tōng)過修改代碼實現。一起來(lái)看看吧(ba)。
效果如圖:
pbootcms,pbootcms點贊量,pbootcms閱讀量
操作(zuò)方法:
1)打開(kāi)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(‘修改內(nèi)容訪問量成功!’);
success(‘修改成功!’, – 1);
} else {
alert_back(‘修改失敗,無任何內(nèi)容!’);
}
break;
添加完畢保存後
2)再打開(kāi)/apps/admin/model/content/ContentModel.php文件
在每一個(gè)如下代碼中添加’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)打開(kāi)/apps/admin/view/default/content/content.html文件
找到
<th>訪問量</th>
下面添加
<th>點贊量</th>
再找到
<td>value->visits</td>
改為(wèi)
<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>
這樣就可(kě)以了~
*請(qǐng)認真填寫需求信息,我們會(huì)在24小(xiǎo)時(shí)內(nèi)與您取得(de)聯系。