首页 技术 正文
技术 2022年11月15日
0 收藏 828 点赞 3,295 浏览 1269 个字

ecshop本身的广告调用规则是:对某个广告位下的广告列表随机显示其中一条。

而我们有时需要将某个广告位下的所有广告全部显示出来,那么如何处理呢,下面就自己做了一个函数:

\includes\lib_common.php  在最下面增加一个函数:根据传入的广告id,获取广告数组,全站通用。

 function get_position_ads($id)
{
$sql = "select * from " . $GLOBALS['ecs']->table('ad') . " where position_id = ".$id." AND enabled = 1 order by ad_id";
$rows = $GLOBALS['db']->getAll($sql);
if($rows )
{
$sql = "select ad_width,ad_height from " . $GLOBALS['ecs']->table('ad_position') . " where position_id = ".$id." limit 1";
$ad_position = $GLOBALS['db']->getRow($sql);
foreach($rows as &$row )
{
$row['pic']= 'data/afficheimg/'.$row['ad_code'];
$row['width'] = $ad_position['ad_width'];
$row['height'] = $ad_position['ad_height'];
}
}
return $rows;
}

然后显示页加入smarty语句,

例如我们需要在首页加入一个广告列表,就在\index.php中查找assign_template();

在这句话的下面加入

$smarty->assign('addiy', get_position_ads(1));

最后在模板文件中把数据调用出来,这也是smarty引擎通用的方法。

打开\themes\default\index.dwt 模板,引入:

{foreach from=$addiy item=addiylist}
<a href="{$addiylist.ad_link}" rel="external nofollow" title="{$addiylist.ad_name}" target="_blank">
<img src="{$addiylist.pic}" width="980" height="387" alt="{$addiylist.ad_name}" />
</a>
{/foreach}

相关内容:

ecshop添加广告位方法和常规调用

http://zhidao.baidu.com/link?url=X-uj76er80lDun5seoCSMHnvHbFCdwxUcmSwZnwVSivKutuza8os79qHiIrZlyYPpPfxsdJnQGeS_Z-AEs1wk4Mm-fEEEcSVMhs_lIWN7C_

ecshop中广告位的ID是在哪里查看?

ecshop当中的广告位ID,具体查看也是状态栏

ecshop调用后台指定广告位下所有广告循环

更多ecshop问题参考:http://www.zuimoban.com/php/ecshop/

下一篇: java25
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,958
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,482
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,328
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,111
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,743
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,777