如何调用ecshop的轮播图的图片信息

/


/为了在页面中调用后台上传的图片地址和对应的链接,我们可以在index.php最下面增加一个函数

/***获取首页广告***/
function get_index_ad()
{
    $flashdb = array();
    if (file_exists(ROOT_PATH . DATA_DIR . '/flash_data.xml'))
    {
         $uri = $GLOBALS['ecs']->url();
                 $content = file_get_contents(ROOT_PATH . DATA_DIR . '/flash_data.xml');
                 $xml = simplexml_load_string($content);
         if (!empty($xml))
         {
            foreach ($xml as $key => $item)
            {
                $attr = $item->attributes();
                                $item_url =strpos($attr['item_url'], 'http') === false? $uri . $attr['item_url']: $attr['item_url'];
                $flashdb[] = array('src'=>trim($item_url),'url'=>trim($attr['link']),'text'=>trim($attr['text']),'sort'=>trim($attr['sort']));
            }
        }
    }
    return $flashdb;

}

$smarty->assign('index_ad',    get_index_ad());        // 首页轮播

然后就可以在index.dwt中就可以循环显示出图片了

{foreach from=$index_ad item=iad}
        <a href="{$iad.url}" target="_blank" tabindex="{$iad.text}"><img src="{$iad.src}" /></a>
        {/foreach}




输出的数组是



array (size=6)
  0 => 
    array (size=4)
      'src' => string 'http://localhost/lvyou/data/afficheimg/20160128exxdnz.jpg' (length=57)
      'url' => string 'http://' (length=7)
      'text' => string '' (length=0)
      'sort' => string '0' (length=1)
  1 => 
    array (size=4)
      'src' => string 'http://localhost/lvyou/data/afficheimg/20160129prsrpo.png' (length=57)
      'url' => string 'http://mb.ecmoban.com/kuajingtong/' (length=34)
      'text' => string '' (length=0)
      'sort' => string '1' (length=1)
  2 => 
    array (size=4)
      'src' => string 'http://localhost/lvyou/data/afficheimg/20160129vfrgku.jpg' (length=57)
      'url' => string 'http://dsc.ecmoban.com/' (length=23)
      'text' => string '' (length=0)
      'sort' => string '2' (length=1)
  3 => 
    array (size=4)
      'src' => string 'http://localhost/lvyou/data/afficheimg/20160129bcmitn.jpg' (length=57)
      'url' => string 'http://www.ecjia.com/' (length=21)
      'text' => string '' (length=0)
      'sort' => string '3' (length=1)
  4 => 
    array (size=4)
      'src' => string 'http://localhost/lvyou/data/afficheimg/20150608boezpt.png' (length=57)
      'url' => string 'http://www.ectouch.cn/' (length=22)
      'text' => string '' (length=0)
      'sort' => string '4' (length=1)
  5 => 
    array (size=4)
      'src' => string 'http://localhost/lvyou/data/afficheimg/20160129pcigev.png' (length=57)
      'url' => string 'http://www.ecmoban.com/topic/wfx/index.html' (length=43)
      'text' => string '' (length=0)
      'sort' => string '5' (length=1)


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ecshop首页幻灯js版 参考 www.chinahongjiu.net 使用方法 1、将文件夹下载到 data/flashdata 中 2、修改admin文件夹中的flashplay.php 大约 870行添加 case 'Myjs';注意文件夹名称要一直,否则更新不了。这样就可以到后台调用了 样式自己调整 3、更新了js ,解决的部分bug,替换即可 var mylnk=""; var mytxt=""; var mypic=""; var s1="",s2="",s3=""; function show_flash() { mylnk=links.split("|"); mytxt=texts.split("|"); mypic=pics.split("|"); s1="",s2="",s3=""; cpn=mylnk.length; for(i=0;i<mylnk.length;i++) { s1+='<li id="Myop'+i+'" ></li>'; s2+='<li id="Myjs'+i+'" onmouseover="Myjsch(\'Myjs'+i+'\',\''+mypic[i]+'\')" onmouseout="Myjscl(\'Myjs'+i+'\')" ref="'+mypic[i]+'"><a href="'+unescape(mylnk[i])+'">'+mytxt[i]+'</a></li>'; } document.getElementById('flash_cycle_image').innerHTML = '<div class="i_topcenter">'+"\n"+'<div class="slides" >'+"\n"+'<a href="'+mylnk[0]+'" id="slide-a"><img id="slide-pic" src="'+mypic[0]+'"/></a>'+"\n"+'<ul class="slide-li" id="op">'+"\n"+s1+"\n"+'</ul><ul class="slide-li" id="slide-txt">'+"\n"+s2+'</ul>'+"\n"+'</div>'+"\n"+' </div>'; document.getElementById("Myjs0").style.background="#ff0000"; if(document.all)document.getElementById("slide-pic").filters[0].enabled=false; ss=""; timen=2000; cp=0; obj=document.getElementById("slide-pic"); cpn=document.getElementById("slide-txt").getElementsByTagName("li").length; ss= window.setInterval(function() { if(cp<cpn-1){cp++; } else{ cp=0 } if(document.all){ obj.filters.blendtrans.Apply(); obj.filters[0].enabled=false; obj.filters.blendtrans.Play(); } obj.src=document.getElementById("Myjs"+cp).getAttribute("ref"); for(j=0;j<cpn;j++){ if(j==cp){ document.getElementById("Myjs"+j).style.background="#ff0000"; document.getElementById("slide-a").href=unescape(mylnk[j]); } else { document.getElementById("Myjs"+j).style.background=""; } } },timen); //mystart(); } LoadCSS("data/flashdata/Myjs/mycss.css"); $importjs('data/flashdata/Myjs/data.js', show_flash); function Myjsch(sid,ref) { window.clearInterval(ss); if(document.all){ obj.filters.blendtrans.Apply(); obj.filters[0].enabled=false; obj.filters.blendtrans.Play(); } obj.src=ref; for(i=0;i<cpn;i++) { if("Myjs"+i==sid) { document.getElementById("Myjs"+i).style.background="#cc3333"; document.getElementById("slide-a").href=unescape(mylnk[i]); } else { document.getElementById("Myjs"+i).style.background=""; } } } function Myjscl(sid) { cp=sid.substring(4); ss= window.setInterval(function() { if(cp<cpn-1){cp++; } else{ cp=0 } if(document.all){ obj.filters.blendtrans.Apply(); obj.filters[0].enabled=false; obj.filters.blendtrans.Play(); } obj.src=document.getElementById("Myjs"+cp).getAttribute("ref"); for(j=0;j<cpn;j++){ if(j==cp){ document.getElementById("Myjs"+j).style.background="#ff0000"; document.getElementById("slide-a").href=unescape(mylnk[j]); } else { document.getElementById("Myjs"+j).style.background=""; } } },timen); }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值