关于在ECSHOP首页调用$tag商品标签的方法

2016-09-11 20:38 来源:www.chinab4c.com 作者:ecshop专家

首先在ecshop模板文件中index.dwt 中插入如下代码:
<div id="alltag">
      <div class="sortbg">
        <div id="alltag_left"></div>
        <div id="alltag_right"></div>        
      </div>
      <div class="alltagcontent" style="height:50px;">
        <!-- {if $tags} -->
          <!--{foreach from=$tags item=tag}-->
          <span style="font-size:{$tag.size}; line-height:36px;"> <a href="search.php?keywords={$tag.tag_words|escape:url}" style="color:{$tag.color}">
          {if $tag.bold}
          <b>{$tag.tag_words|escape:html}</b>
          {else}
          {$tag.tag_words|escape:html}
          {/if}
          </a>
         </span>
          <!--{/foreach}-->
          <!-- {else} -->
          <span style="margin:2px 10px; font-size:14px; line-height:36px;">{$lang.no_tag}</span>
          <!-- {/if} -->
      </div>
    </div>
然后再在 index.php中插入如下代码:
/*  调用标签云*/   
    assign_dynamic('tag_cloud');
    $tags = get_tags();
    $smarty->assign('tags', $tags);