网站开发 · 2025年4月23日

如何ecshop调用所有商品的标签云

Ecshop 系统首页也会看到不少的云标签,云标签的作用主要就是聚合相关信息来用的,比方我们上传的商品有多条,除了分为大类目之外,还能够分为聚合的小类,这些小类就是我们常常看到的 tag 标签了,最大的优点就是灵敏度较大,想怎样写就怎样写,不受分类的限制,好了,就来教下大家如何在 ecshop 首页来调用这些聚合标签吧。

第一步:翻开tag_cloud.php,将如下代码:
assign_dynamic(‘tag_cloud’);
$tags = get_tags();
if (!empty($tags))
{
include_once(ROOT_PATH . ‘includes/lib_clips.php’);
color_tag($tags);
}
$smarty->assign(‘tags’, $tags);
这段代码复制下来。

第二步:打开index.php,找到如下代码:
$smarty->assign(‘shop_notice’, $_CFG[‘shop_notice’]); // 商店公告
粘贴到这行代码下。
第三步:然后在index.dwt页面里,直接复制循环代码就可以了

<!– {if $tags} –>
<!– 标签云开始 {foreach from=$tags item=tag}–>
<span style=”font-size:{$tag.size}; line-height:36px;”> <a href=”{$tag.url}” style=”color:{$tag.color}”>
{if $tag.bold}
<b>{$tag.tag_words|escape:html}</b>
{else}
{$tag.tag_words|escape:html}
{/if}
</a>
<!– {if $tags_from eq ‘user’} –>
<a href=”user.php?act=act_del_tag&amp;tag_words={$tag.tag_words|escape:url}&amp;uid={$tag.user_id}” title=”{$lang.drop}”> <img src=”images/drop.gif” alt=”{$lang.drop}” /> </a>&nbsp;&nbsp;
<!– {/if} –>
</span>
<!– 标签云结束 {/foreach}–>
<!– {else} –>
<span style=”margin:2px 10px; font-size:14px; line-height:36px;”>{$lang.no_tag}</span>
<!– {/if} –>