博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ecshop调用后台指定广告位下所有广告循环
阅读量:6932 次
发布时间:2019-06-27

本文共 1312 字,大约阅读时间需要 4 分钟。

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

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

 

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

1 function get_position_ads($id) 2 { 3     $sql = "select * from " . $GLOBALS['ecs']->table('ad') . " where position_id = ".$id." AND enabled = 1 order by ad_id"; 4     $rows = $GLOBALS['db']->getAll($sql); 5     if($rows ) 6     { 7      $sql = "select ad_width,ad_height from " . $GLOBALS['ecs']->table('ad_position') . " where position_id = ".$id." limit 1"; 8      $ad_position = $GLOBALS['db']->getRow($sql); 9      foreach($rows as &$row )10      {11      $row['pic']= 'data/afficheimg/'.$row['ad_code'];12      $row['width'] = $ad_position['ad_width'];13      $row['height'] = $ad_position['ad_height'];14      }15     }16     return $rows;17 }

 

然后显示页加入smarty语句,

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

 

在这句话的下面加入

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

 

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

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

{
foreach from=$addiy item=addiylist} {<div></div>   $addiylist.ad_name}{
/foreach}

 

 


 

 

相关内容:

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

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

 

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

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

 

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

转载地址:http://xpgjl.baihongyu.com/

你可能感兴趣的文章
Elasticsearch索引原理
查看>>
SVM核技巧之终极分析
查看>>
hdu2089 不要62 数位DP
查看>>
GetSchema取得数据库架构,无法取得列的Description属性的解决方法
查看>>
jQuery链式操作
查看>>
课本235页2-3题
查看>>
Windows CMD命令大全
查看>>
我的天哪,,我我, 我, 我,进入了恐慌季,我到转折点了吗?
查看>>
UVA1665 Islands (并查集)
查看>>
织梦网站底部的Power by DedeCms怎么去掉?
查看>>
SpringMVC源码分析-400异常处理流程及解决方法
查看>>
SQL中的取整函数FLOOR、ROUND、CEIL、TRUNC、SIGN
查看>>
第十八天笔记
查看>>
document.body.scrollTop or document.documentElement.scrollTop
查看>>
使用Maven创建一个Spring MVC Web 项目
查看>>
使用Redis模拟简单分布式锁,解决单点故障的问题
查看>>
[笔记]linux磁盘管理
查看>>
error C2065: 'theApp' : undeclared identifier
查看>>
linux中的颜色控制
查看>>
[SOJ #48]集合对称差卷积
查看>>