Magento 默认的已经有popular search的内容了,位于底部的 search terms 链接结果页面中,所以要实现 在边栏显示 popular search块只需要在对应的位置调出相应的内容即可。
修改xml文件(一般是 catalog.xml)在对应位置添加以下调用代码
<block type=”catalogsearch/term” name=”sidebar.seo.searchterm” template=”catalogsearch/sideterm.phtml”/>
进入template/catalogsearch/目录 拷贝term.phtml 文件为sideterm.phtml
方便我们修改边栏样式,而不会影响到默认的调用
经常在网站使用一段时间之后,搜索的内容细则较多,这样就使边栏调用出来的popular search 过长,影响页面美观。 这时我们再次通过对sideterm.phtml进行简单的修改,来缩减边栏显示的热门搜索条目,
<?php
$t_limit = 0.4;
foreach ($this->getTerms() as $_term):
if($_term->getRatio() > $t_limit) :
?>
….
<?php
endif;
endforeach;
?>
($t_limit 越大 显示的条目越少,取值范围0~1 ,参考了默认显示中控制字体大小的代码片段)
且记如此,有更好的方法 或 意见建议 欢迎留言
发表评论: