13+年专注全栈开发,承接小程序开发,分销系统定制,网站建设、搬家、搭建,二次开发等一站服务,欢迎咨询
我们在ecshop模板制作当中,有时候对广告的调用不能局限于默认的ecshop的表情规则,比如要调用后台指定广告位下所有广告循环,如何处理呢?最模板抽空做了个函数: 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->assign('zuimoban', get_position_ads(1)); 后面的1 指的是广告位ID. 模板里引入: {foreach from=$zuimoban item=zuimobanlist}<td><a href="{$zuimobanlist.ad_link}" title="{$zuimobanlist.ad_name}" target="_blank"><img src="{$zuimobanlist.pic}" width="980" height="387" alt="{$zuimobanlist.ad_name}" /></a></td> {/foreach} 至此模板上调用指定广告位就正常显示了。 以后只需改指定广位下广告就行
ecshop调用后台指定广告位下所有广告循环_
ecshop教程
栏目文章由:
源码庄整理发布,转载请注明来源。
来源地址:https://www.codenet.cc/article/details/310.html
本站资源未标注正版授权软件均为会员提供或网上搜集,版权归原作者所有,如需商业用途或转载请与原作者联系;
发布的文章及附件仅限用于学习和研究目的,请勿用于商业或违法用途!如有侵权,请及时联系我们!
《更多用户服务协议声明》