A-A+
	ecshop首页如何调用商品tag标签
tag 标签是网站信息的聚合,是为了更方便的索引人们找到自己喜欢的内容,这种 tag 标签的显示在个人博客中居多,比如小虎博客的标签云,除了方便人们的索引,更是对 seo 有较大的帮助,在 ecshop 中,在其默认首页中是不显示任何的 tag 标签的,tag 标签只是在商品的详情页中显示,所以这也由此可以判定一点,在 ecshop 中,tag 的函数是有的,只是在首页没有调用出来而已。
下面就让我们看一下如何在 ecshop 中把商品 tag 聚合信息给调用出来吧。
首先在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);