请选择 进入手机版 | 继续访问电脑版

叶子网络bbs论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 19956|回复: 0

[ecshop] ecshop怎样在新主页模板里调用首页主广告

[复制链接]

0

主题

3

帖子

8

积分

超级版主

Rank: 8Rank: 8

积分
8
发表于 2015-12-7 17:42:41 | 显示全部楼层 |阅读模式
第一步:index.php里加了一个方法,调用XML文件;function get_flash_xml()

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;
}

第二步:
在index.php中找到 $smarty->assign('shop_notice',     $_CFG['shop_notice']);       // 商店公告
在下面添加

/*jdy add 0816 添加首页幻灯插件*/
$smarty->assign("flash",get_flash_xml());
$smarty->assign('flash_count',count(get_flash_xml()));

第三:
直接在index.dwt页面中调用循环就可以了

<!--{foreach from=$flash name=myflash item=flash}-->
   
  <LI><A href="{$flash.url}" target=_blank><IMG
alt="" src="{$flash.src}" ></A> </LI>
  <!--{/foreach}-->
回复

使用道具 举报

手机版|Archiver|叶子官网|杭州轩翼网络科技有限公司 ( 浙ICP备17027999号

GMT+8, 2024-3-29 22:18 , Processed in 0.248654 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表