+ 收藏我們

網(wǎng)站模板

網(wǎng)站模板搜索
網(wǎng)站模板 > cms教程 > pbootcms教程 >

PBOOTCMS增加內(nèi)容首圖為縮略圖按鈕及內(nèi)容圖片為多圖按鈕

AB模板網(wǎng) / 2023-12-05
有一些朋友的網(wǎng)站前端不需要縮略圖,只需要個(gè)別文章顯示縮略圖,PbootCMS模板默認(rèn)自動(dòng)提取文章里的圖片作為縮略圖。其實(shí)可以增加一個(gè)按鈕,判斷下就可以。最終實(shí)現(xiàn)效果如下:

PBOOTCMS增加內(nèi)容首圖為縮略圖按鈕及內(nèi)容圖片為多圖按鈕

找到文件apps\admin\view\default\content\content.html(在代碼340行及740行,添加以下代碼)

<div class="layui-form-item">
<label class="layui-form-label">內(nèi)容圖片設(shè)置</label>
<div class="layui-input-block">
<input type="checkbox" name="contenttopic" value="1" title="內(nèi)容首圖設(shè)置縮略圖">
<input type="checkbox" name="contenttopics" value="1" title="內(nèi)容圖片設(shè)置多圖">
</div>
</div>
找到文件apps\admin\controller\content\ContentController.php
在代碼96/428行

$contenttopic = post('contenttopic');//設(shè)置內(nèi)容首圖按鈕
$contenttopics = post('contenttopics');//設(shè)置內(nèi)容圖片為多圖按鈕
在代碼136/468行處添加

// 提取文章第一張圖為縮略圖
if ($contenttopic && preg_match('/<img\s+.*?src=\s?[\'|\"](.*?(\.gif|\.jpg|\.png|\.jpeg))[\'|\"].*?[\/]?>/i', decode_string($content), $srcs) && isset($srcs[1])) {
    $ico = $srcs[1];
}

// 設(shè)置內(nèi)容圖片為多圖,不適用內(nèi)容圖片很多的情況 adminbuy.cn
if ($contenttopics && preg_match_all('/<img\s+.*?src=\s?[\'|\"](.*?(\.gif|\.jpg|\.png|\.jpeg))[\'|\"].*?[\/]?>/i', decode_string($content), $srcs)) {
    $strsrcs = implode(",", $srcs[1]);
    $pics = $strsrcs;
}

以上是文章添加的代碼,文章修改的代碼也是一樣

文章搜集與網(wǎng)絡(luò),如有侵權(quán)請(qǐng)聯(lián)系本站,轉(zhuǎn)載請(qǐng)說明出處:http://www.warewashingadvisors.com/pbootcmsjs/10848.html
首頁 pbootcms模板 html模板 會(huì)員中心
 
咨詢
QQ在線咨詢

如無回復(fù)
請(qǐng)加下面的微信

添加微信客

微信客服
wwwadminbuycn