A-A+

ecshop首页如何调用商品tag标签

2015年09月02日 PHP开源系统 暂无评论 阅读 13 views 次

tag 标签是网站信息的聚合,是为了更方便的索引人们找到自己喜欢的内容,这种 tag 标签的显示在个人博客中居多,比如夏日博客的标签云,除了方便人们的索引,更是对 seo 有较大的帮助,在 ecshop 中,在其默认首页中是不显示任何的 tag 标签的,tag 标签只是在商品的详情页中显示,所以这也由此可以判定一点,在 ecshop 中,tag 的函数是有的,只是在首页没有调用出来而已。

下面就让我们看一下如何在 ecshop 中把商品 tag 聚合信息给调用出来吧。

首先在ecshop模板文件中index.dwt 中插入如下代码:

  1. <div id="alltag">  
  2.       <div class="sortbg">  
  3.         <div id="alltag_left"></div>  
  4.         <div id="alltag_right"></div>          
  5.       </div>  
  6.       <div class="alltagcontent" style="height:50px;">  
  7.         <!-- {if $tags} -->  
  8.           <!--{foreach from=$tags item=tag}-->  
  9.           <span style="font-size:{$tag.size}; line-height:36px;"> <a href="search.php?keywords={$tag.tag_words|escape:url}" style="color:{$tag.color}">  
  10.           {if $tag.bold}  
  11.           <b>{$tag.tag_words|escape:html}</b>  
  12.           {else}  
  13.           {$tag.tag_words|escape:html}  
  14.           {/if}  
  15.           </a>  
  16.          </span>  
  17.           <!--{/foreach}-->  
  18.           <!-- {else} -->  
  19.           <span style="margin:2px 10px; font-size:14px; line-height:36px;">{$lang.no_tag}</span>  
  20.           <!-- {/if} -->  
  21.       </div>  
  22.     </div>  

然后再在 index.php中插入如下代码:

  1. /*  调用标签云*/     
  2.     assign_dynamic('tag_cloud');  
  3.     $tags = get_tags();  
  4.     $smarty->assign('tags', $tags);  
标签:

给我留言