修正广告

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

View File

@ -87,16 +87,29 @@
},{
field: 'title',
title: '广告名称'
},
{
},{
field: 'image',
title: '广告图片',
formatter:function (value,row,index) {
let html ='<img src="'+value+'" alt="" width="50px;">';
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',
title: '链接地址',
}, {

View File

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

View File

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

View File

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