一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

ecshop怎么以幻灯版调用首页主广告显示

时间:2014-06-09 编辑:简简单单 来源:一聚教程网

我的默认的是index_ad.lbi模板有一个$flash变量了,但在搜索搜索没发现

 代码如下 复制代码


   



  •     


  •     {$smarty.foreach.no.iteration}
       

  • 然后我在index.php文件搜索flash变量没有,只发现这样一个代码

     代码如下 复制代码

    /* 首页主广告设置 */
    $smarty->assign('index_ad',     $_CFG['index_ad']);
        if ($_CFG['index_ad'] == 'cus')
        {
            $sql = 'SELECT ad_type, content, url FROM ' . $ecs->table("ad_custom") . ' WHERE ad_status = 1';
            $ad = $db->getRow($sql, true);
            $smarty->assign('ad', $ad);
    }

    发现没办法使用了,我调用时也不会显示广告主的广告,于是网上搜索一下看到一段这样的文字

    在首页index.php的代码:$smarty->assign('shop_notice',     $_CFG['shop_notice']);       // 商店公告

    在这个代码下面加入下面代码:

     代码如下 复制代码

    $smarty->assign("flash",get_flash_xml());
    $smarty->assign('flash_count',count(get_flash_xml()));

    如果以上两步没有调用首页主广告,然后再index.php中加入如下代码:

     代码如下 复制代码

    function get_flash_xml()
    {
    $flashdb = array();
    if (file_exists(ROOT_PATH . DATA_DIR . '/flash_data.xml'))
    {
    // 兼容v2.7.0及以前版本
    if (!preg_match_all('/item_url="([^"]+)"slink="([^"]+)"stext="([^"]*)"ssort="([^"]*)"/', file_get_contents(ROOT_PATH . DATA_DIR . '/flash_data.xml'), $t, PREG_SET_ORDER))
    {
    preg_match_all('/item_url="([^"]+)"slink="([^"]+)"stext="([^"]*)"/', file_get_contents(ROOT_PATH . DATA_DIR . '/flash_data.xml'), $t, PREG_SET_ORDER);
    }
    if (!empty($t))
    {
    foreach ($t as $key => $val)
    {
    $val[4] = isset($val[4]) ? $val[4] : 0;
    $flashdb[] = array('src'=>$val[1],'url'=>$val[2],'text'=>$val[3],'sort'=>$val[4]);
    //print_r($flashdb);
    }
    }
    }
    return $flashdb;
    }


    这样再调用发现可以显示了,不过中间有一个小细节就是我把function get_flash_xml()函数放在了

     代码如下 复制代码

    $smarty->assign("flash",get_flash_xml());
    $smarty->assign('flash_count',count(get_flash_xml()));

    下面会提示函数未定义,于时我把它放到index.php文件最后面就可以了,这个具体原因我也不说了大家自行测试一下吧。

    热门栏目