ECSHOP下后台模板设置中增加新的自定义项目库标签设置

需要在产品展示左侧添加一个热销商品栏目,但是后台模板设置中,商品详细页并没有热销商品这个项目标签。没办法只有自己想办法增加一个。下面记录下解决方法,希望能帮助到大家。

1、首先的增加一个lbi模板文件,比如我的详细页左侧热销商品,用已有的goods_related.lbi复制成一个新的goods_hot.lbi,这样做的目的,主要是我想直接借用浏览历史这个栏目的样式。还是贴下我的goods_related.lbi代码:

  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  2. <!-- {if $hot_goods} -->
  3. <div class="box">
  4.      <div class="box_1">
  5.       <h3><span>{$lang.releate_goods}</span></h3>
  6.       <div class="boxCenterList clearfix">
  7.       <!--{foreach from=$hot_goods item=goods}-->
  8.         <ul class="clearfix">
  9.           <li class="goodsimg"><a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name}" class="B_blue" /></a></li>
  10.           <li>
  11.         <a href="{$goods.url}" title="{$goods.name}">{$goods.short_name}</a><br />
  12.         <!-- {if $goods.promote_price neq 0} -->
  13.         {$lang.promote_price}<font class="f1">{$goods.formated_promote_price}</font>
  14.         <!-- {else} -->
  15.         {$lang.shop_price}<font class="f1">{$goods.shop_price}</font>
  16.         <!-- {/if} -->
  17.           </li>
  18.         </ul>
  19.         <!--{/foreach}-->
  20.       </div>
  21.      </div>
  22.     </div>
  23. <div class="blank5"></div>
  24. <!-- {/if} -->
复制代码


        2、在goods.php文件中加上热销商品的调用程序

  1. $smarty->assign('hot_goods', get_recommend_goods('hot2'));     // 热销商品
复制代码

  
        3、在后台admin/includes/lib_template.php 文件中增加goods_hot一项:

  1. /* 每个模板允许设置的库项目 */
  2. $page_libs = array(
  3.    
  4.     'goods' => array(
  5.                 '/library/goods_hot.lbi' => 3,
复制代码

       这部分代码我只是贴出一个样子,具体情况可以自己去研究,设置为3目的是改项目标签为可编辑数目状态。


        4、在语言包文件夹下admin/template.php中,增加语言项:

  1. /* 每一个库项目的描述 */
  2. $_LANG['template_libs']['goods_hot'] = '详细页热销商品';
复制代码


        5、找到模板文件夹下的libs.xml文件,在相应的goods.dwt下增加标签 <lib>goods_hot</lib>

        6、找到function get_recommend_goods() 函数,里面增加hot2参数相对应的程序,这个就不多讲解了,可以自己研究研究,不是很难。   


好了,现在到后台的设置模板栏目下,选择商品详细页,就可以看到新增加的项目标签了。
可能还有些地方不够完善,或者存在问题,暂时没时间做太多测试和完善。

文章来源:http://www.uswei.com/bbs/thread-4-1-1.html

posted @ 2013-02-22 10:14  helloyb  阅读(824)  评论(0编辑  收藏  举报