您好!欢迎来到e资源!本站资源24小时自动发货,海量精品课程资源免费下载!

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

我们在ecshop模板制作当中,有时候对广告的调用不能局限于默认的ecshop的表情规则,比如要调用后台指定广告位下所有广告循环,如何处理呢?最模板抽空做了个函数:function get_position_ads($id){ $sql ...
我们在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}   至此模板上调用指定广告位就正常显示了。 以后只需改指定广位下广告就行
开通vip
首页 导航 会员 客服 微信
QQ 微信 邮箱 TOP