修正广告

This commit is contained in:
liyukun 2021-08-13 00:56:19 +08:00
parent b38f4e5bf9
commit ecf74466b6
5 changed files with 32 additions and 27 deletions

View File

@ -77,7 +77,7 @@ class Poster extends AuthController
$form[] = Elm::input('sort','排序')->col(10); $form[] = Elm::input('sort','排序')->col(10);
$form[] = Elm::select('position', '位置')->options(function(){ $form[] = Elm::select('position', '位置')->options(function(){
$options = []; $options = [];
foreach(['首页', '首页右侧','文章页面'] as $k=>$v){ foreach(['顶部页签', '右侧广告位','文章页面'] as $k=>$v){
$options[] = Elm::option($k, $v); $options[] = Elm::option($k, $v);
} }
return $options; return $options;
@ -105,7 +105,7 @@ class Poster extends AuthController
$form[] = Elm::input('sort','排序',$ainfo['sort'])->col(10); $form[] = Elm::input('sort','排序',$ainfo['sort'])->col(10);
$form[] = Elm::select('position', '位置',$ainfo['position'])->options(function(){ $form[] = Elm::select('position', '位置',$ainfo['position'])->options(function(){
$options = []; $options = [];
foreach(['首页', '首页右侧','文章页面'] as $k=>$v){ foreach(['顶部页签', '右侧广告位','文章页面'] as $k=>$v){
$options[] = Elm::option($k, $v); $options[] = Elm::option($k, $v);
} }
return $options; return $options;

View File

@ -87,16 +87,29 @@
},{ },{
field: 'title', field: 'title',
title: '广告名称' title: '广告名称'
}, },{
{
field: 'image', field: 'image',
title: '广告图片', title: '广告图片',
formatter:function (value,row,index) { formatter:function (value,row,index) {
let html ='<img src="'+value+'" alt="" width="50px;">'; let html ='<img src="'+value+'" alt="" width="50px;">';
return html; return html;
} }
}, },{
{ field: 'position',
title: '广告图片',
formatter:function (value,row,index) {
switch (value) {
case 1:
return '顶部页签';
case 2:
return '右侧广告位';
case 3:
return '文章页面';
default:
return '顶部页签';
}
}
},{
field: 'url', field: 'url',
title: '链接地址', title: '链接地址',
}, { }, {

View File

@ -208,11 +208,9 @@ class Zz extends TagLib{
*/ */
public function tagAdvert($tag,$content) public function tagAdvert($tag,$content)
{ {
$type=isset($tag['type'])?$tag['type']:'text'; $type=isset($tag['type'])?$tag['type']:1;
$type=$type=='text'?0:1;
$row=isset($tag['row'])?$tag['row']:100; $row=isset($tag['row'])?$tag['row']:100;
$void=isset($tag['void'])?$tag['void']:'field'; $void=isset($tag['void'])?$tag['void']:'field';
$parse = '<?php '; $parse = '<?php ';
$parse .= '$__LIST__ ='."tpl_get_advert($type,$row);"; $parse .= '$__LIST__ ='."tpl_get_advert($type,$row);";
$parse .= ' ?>'; $parse .= ' ?>';

View File

@ -566,13 +566,14 @@ function tpl_get_banner($type, $row)
*/ */
function tpl_get_advert($type, $row) function tpl_get_advert($type, $row)
{ {
$advertList = cache('DATA_BANNER'); $advertList = cache('DATA_ADVERT'.'_'.$type);
if ($advertList === null) { if ($advertList === null) {
$advertList = Db::name('advert')->where('status', 1)->order('sort asc')->limit($row)->select(); if ($type > 0) {
cache('DATA_ADVERT', $advertList); $advertList = Db::name('advert')->where('position',$type)->where('status', 1)->order('sort desc')->limit($row)->select();
} }else{
if ($type === 0) { $advertList = Db::name('advert')->where('status', 1)->order('sort desc')->limit($row)->select();
return $advertList; }
cache('DATA_ADVERT'.'_'.$type, $advertList);
} }
$advertListTemp = []; $advertListTemp = [];
foreach ($advertList as $key => $item) { foreach ($advertList as $key => $item) {

View File

@ -442,23 +442,16 @@
</div> </div>
</li> </li>
</div> </div>
{zz:advert row="3" type="2"}
<div class="aside-box"> <div class="aside-box">
<h2 class="widget-title">免费简单好用的网站服务器运维面板</h2> <h2 class="widget-title">{$field['title']}</h2>
<a href="javascript:;"> <a href="{$field['url']}" target="_blank">
<img width="300" height="191" src="/uploads/article/2021/03/bt面板-300x191.png" <img width="300" height="191" src="{$field['image']}"
class="image wp-image-559 attachment-medium size-medium" alt="" class="image wp-image-559 attachment-medium size-medium" alt=""
loading="lazy" style="max-width: 100%; height: auto;"> loading="lazy" style="max-width: 100%; height: auto;">
</a> </a>
</div> </div>
<div class="aside-box"> {/zz:advert}
<h2 class="widget-title">拥有一个自己的网站服务器</h2>
<a href="javascript:;">
<img width="300" height="164"
src="/uploads/article/2021/03/440-240_画板-1-300x164.jpg"
class="image wp-image-574 attachment-medium size-medium" alt=""
loading="lazy" style="max-width: 100%; height: auto;">
</a>
</div>
</div> </div>
</div> </div>
</div> </div>