Magento仅显示x个属性,之后显示更多选项


Magento show only x number of attributes, after that show more options

我还有一个问题,在我的网站上我有分层的水平导航。它工作得很好,但现在我已经修改了它。

对于某些产品类别,例如。 12 个属性将出现在分类级别上,但我只想显示 5 个属性,之后您必须单击显示更多选项。

我内置了一个断线,规定只显示 5 个属性,所以只剩下显示更多选项。

我认为最简单的方法是将这些附加链接放在单独的<div />或其他元素中,并将其设置为display: none;样式。然后我会使用一个简单的JavaScript代码在点击链接时显示它们Show more

例如

<a href="javascript:void(0)" id="show-more-link">Show more</a>
<div style="display:none;" id="other-attributes">(the content)</div>
<script type="text/javascript">
//use prototype for this matter
$('show-more-link').observe('click', function(){
  if ($('other-attributes')).visible() { //hide
    $('other-attributes').hide();
    this.update('Show more');
  } else {
    $('other-attributes').show();
    this.update('Show less');
  }
  return false;
});
</script>

我还没有测试过它,但我认为这样的东西应该有效。