帖子原址:http://www.magentocommerce.com/boards/viewthread/49255/
★把下面的代码,拷贝到记事本,以UTF-8形式另存为 /app/design/frontend/default/f002/template/catalogsearch/term.phtml
ENG:copy the code below into Notepad, Save it as /app/design/frontend/default/f002/template/catalogsearch/term.phtml in UTF-8
<?php
/**
* Magento
*来自小方,
*Email: lanshunfang#163.com--Replace # as @
*/
?>
<div class="box base-mini mini-cart">
<div class="head">
<h4><?php echo $this->__('Popular Search Terms') ?></h4>
</div>
<?php if( sizeof($this->getTerms()) > 0 ): ?>
<div class="content" id="popSearchTerms">
<ul class="bare-list">
<?php
$i = 0;
$getRatioSort = $this->getTerms();
//小方添加的,对热门关键字数组进行降序排序
foreach ($getRatioSort as $key => $row) {
$volume[$key] = $row->getRatio();//获取排序用的列标识
}
array_multisort($volume, SORT_DESC, $getRatioSort);//根据获取排序用的列标识,进行排序
foreach ($getRatioSort as $_term)://循环输出排序结果
if ($i>50)//只循环输出最多50个产品
{
break;
}
else if ($_term->getRatio() > 0.5)//热度不得低于0.5
{
?>
<li><a href="<?php echo $this->getSearchUrl($_term) ?>" style="font-size:<?php echo $_term->getRatio()*70+75 ?>%;"><?php echo $this->htmlEscape($_term->getName()) ?></a></li>
<?php
$i++;
}
endforeach; ?>
</ul>
</div>
<?php else: ?>
<div class="note-msg">
<?php echo $this->__('There are no search terms available.'); ?>
</div>
<?php endif ?>
</div>
★在CMS中的首页里面的自定义设计里调用
ENG: Call this in CMS->editing “Home Page"->Custom Design
<reference name="right">
<block type="catalogsearch/term" name="catalogsearch.term" template="catalogsearch/term.phtml" />
</reference>