ecshop教程

ECSHOP循环中实现套用调取广告位的办法

ecshop教程 51源码 2022-11-21 人阅读

在做某客户ECSHOP模板活动列表页面时,添加活动列表的时候,需要添加广告,可是该怎么调用广告位呢?现在ECSHOP模板屋教程网来告诉你,怎样轻松循环中

调用ecshop广告,而且方法简单,操作又便捷:

//第一步:定义index变量

<?php     $index=0;     ?>


//第二步:进入循环

<!-- {foreach from=$list item=val name=name} -->


//第三步:给循环里的index值赋值,依次加1

<?php     $index=$index+1;     $GLOBALS['smarty']->assign('index',$index);     ?>      <div class="list_biaoti" id="tg4"> <h3><i></i>活动 {$smarty.foreach.name.iteration}&nbsp;?&nbsp;&nbsp;{$val.act_name} </h3></div>      <div id="tj4" class="list_tuangou"><div class="list_tt">


// 第四步:调用广告位循环,特别注意ID那里,这里直接调用活动ID是出现错误的,所以这里只能调用刚刚赋值的变量index的值

<?php          $GLOBALS['smarty']->assign('index_image',get_advlist('活动ID'.$index.'-左侧活动图片', 1));      ?>        {foreach from=$index_image item=ad name=index_image}          {if $smarty.foreach.index_image.iteration < 2}      <div class="left"><a href="{$ad.url}"><img src="{$ad.image}" height="263" width="770"></a></div>         {/if}       {/foreach}  {/foreach}


此ecshop调用广告位方法可以运用到多处模板循环套用的地方,活学活用,样式自己定义增加修改哦...

版权声明:文章搜集于网络,如有侵权请联系本站,转载请说明出处:https://www.51yma.cn/jiaocheng/ecshop/690.html
文章来源: