zoukankan      html  css  js  c++  java
  • ecshop调用后台指定广告位下所有广告循环

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

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

    includeslib_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引擎通用的方法。

    打开 hemesdefaultindex.dwt 模板,引入:

    {foreach from=$addiy item=addiylist}
    <a href="{$addiylist.ad_link}" 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问题参考:http://www.zuimoban.com/php/ecshop/

  • 相关阅读:
    Oracle 基本命令
    一个完整的创建用户,创建表空间,授权建表过程
    jQueryMobile之Popup
    data-theme 几种值的样式
    jQueryMobile之listview
    jQueryMobile之弹出对话框
    android EditText内嵌图片
    css 盒子模型
    kms可用激活服务器地址|kms可用激活服务器分享
    本地配置DNS服务器(MAC版)
  • 原文地址:https://www.cnblogs.com/woodk/p/4776384.html
Copyright © 2011-2022 走看看