ecshop首页增加商品楼层

在管理ecshop商城的过程中,有时会增加一个商品分类并把这个商品分类在首页楼层中展示。如果所有的楼层都用完了,那么就需要通过修改程序代码来增加一个楼层。

1.在商城网站源文件根目录中找到themes里的index.dwt和根目录的includes中的lib_goods.php并打开,

  在index.dwt里找到其中一个楼层,这些楼层他们在模板都没有显示的,都是用这个引入到模板中显示的

  <!-- #BeginLibraryItem "/library/cat_goods.lbi" --><!-- #EndLibraryItem -->,根据这个来找到你想

  要找的页面(library/cat_goods.lbi);

2.在index.dwt复制一份楼层放在最后的楼层后面,如代码(这个楼层是我自己写的,有导航分类,和其他的ecshop模板不一样):

<!-- #BeginLibraryItem "/library/recommend_jy.lbi" -->

<style>
.sub-list a{
float: left;
width: 50%;
font-size: 14px;
}
.sub-list a:hover {
color:#ff0000;
}
</style>
<div class="xm-box" id="floor-{$goods_cat.sort_order}" style="clear:both;">
<div class="title">
     <h2 style="">3F&nbsp;&nbsp;&nbsp;&nbsp;商品</h2>
    <a class="more" href="category.php?id=25">更多</a>
  </div>
<div class="row show-grid content">
<div class="col-lg-6 left-img left-{$goods_cat.sort_order}" style="float:left;position:relative;margin-top: 10px;">
{insert name='ads' id=15 num=1}
<div class="category" style="position: absolute;top: 15px;left: 20px; width: 30%;height: 387px;padding: 20px 15px;">
<h3 style=" font-weight:bold;font-size: 24px; margin-top: 35px;margin-bottom: 5px;text-align: center;width:100px">精选分类</h3></br>
<div class="sub-list">
<!--{foreach from=$childcat3 item=cat name=foo}--> 
<!--{if $smarty.foreach.foo.iteration<10}-->

    <a title="{$cat.cat_name}" target="_blank" href="category.php?id={$cat.cat_id}">{$cat.cat_name}</a>
           

  <!--{/if}--> 
<!--{/foreach}-->
</div>
</div>
</div>
<ul style="float:right;width:698px;">
<!--{foreach from=$jy item=goods name=name}-->
<!--{if $smarty.foreach.name.iteration<7}-->
<li style="width:220px;float:left;margin-right:12px;">
<div class="goodsItem goodsItems"  > <a href="{$goods.url}"><img src="{$goods.goods_thumb}" style="margin-top:-10px;height:200px;width: 200px;margin-left: 11px;" alt="{$goods.goods_name|escape:html}" class="goodsimg" /></a><br />
  <p class="f1"><a href="{$goods.url}" title="{$goods.goods_name|escape:html}">{$goods.goods_name}</a></p>
   <p class="all-prices">市场价:<font class="market">{$goods.market_price}</font> <br/>
  本店价:<font class="f1"> 
  <!-- {if $goods.promote_price neq 0} --> 
  {$goods.promote_price} 
  <!-- {else}--> 
  {$goods.shop_price} 
  <!--{/if}--> 
  </font>
  </p>
        </div>
</li>
<!-- {/if} -->
<!-- {/foreach} -->
</ul>
    </div>
    <div class="row show-grid"> </div>
</div>

<input type="hidden" name="cat_goods" class="cat_goods" value="{$goods_cat.id}"/>

 <!-- #EndLibraryItem -->

3.然后在library里创建一个楼层文件recommend_jy.lbi(注意:和2步骤引入的文件名一样,文件名自己定义),把楼层代码复制进来,不要把引入的代码复制;

4.打开根目录的index.php,在大概119行加入代码$smarty->assign('jy',      get_recommend_jy());

还有一个导航分类的代码$smarty->assign('childcat3',       get_child_cat(25));(25是你想调的一级分类id 

5.打开第一步骤打开的文件lib_goods.php,加入如下的代码:

function get_recommend_jy(){
$sql="SELECT * FROM " .$GLOBALS['ecs']->table('category')."AS c"." LEFT JOIN".$GLOBALS['ecs']->table('goods')."AS g ON c.cat_id=g.cat_id".
" WHERE c.parent_id=
25 AND g.goods_is_show=1"." order by g.last_update DESC";
$result3=$GLOBALS['db']->getAll($sql);
foreach ($result3 AS $idx => $row){
$result3[$idx]['url']= build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
}

return $result3;

}

其中的parent_id=2525是你想调的一级分类id 


//分类页调用子分类 不调用三级ecmoban.com

function get_child_cat($parent_id=0)
{
    $sql="SELECT * FROM ".$GLOBALS['ecs']->table('category')." WHERE  parent_id = '$parent_id' AND is_show = 1 " ."order by sort_order asc";
    return $GLOBALS['db']->getAll($sql);
     

}

如果首页不显示图片,在后台改一下就可以了,但是管理体验不是很好

在后台的商品列表里编制商品中

这样就解决了。


第一次写的博客希望不要喷哈。。。。。。。。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值