简体   繁体   English

在Magento中调整分层导航

[英]Tweaking layered navigation in Magento

Im figured out about magento layered navigation. 我想出了有关magento分层导航的信息。 I want to make this navigation with dropdown lists. 我想使用下拉列表进行导航。 Ok, Im found solution. 好的,我找到了解决方案。 After adding filter.phtml and simple coding, I got same stuff as i want. 添加filter.phtml和简单的编码后,我得到了想要的东西。 Except one little detail. 除了一个小细节。 After I choose any attribute filter from dropdown selected filter has disappeared. 从下拉列表中选择任何属性过滤器后,所选过滤器便消失了。 I know this is a standard layered navigation behavior. 我知道这是标准的分层导航行为。 But I want to get all available filters at same places, including selected. 但我想在相同位置(包括选定位置)获得所有可用的过滤器。 How can I do that? 我怎样才能做到这一点?

In my filter.phtml I getting all filters by: 在我的filter.phtml中,通过以下方式获取所有过滤器:

$this->getItems() 

And this method returns array with all NOT selected filters. 并且此方法返回具有所有未选择的过滤器的数组。 Maybe I must call another method, or I must to tweak this one? 也许我必须调用另一种方法,或者我必须对此方法进行调整?

I'm not really sure If I understand your question correctly. 我不确定我能否正确理解您的问题。 I spent some time doing something similar to what I think you are asking for. 我花了一些时间做与我想像的一样的事情。 Basically I had a client who wanted all of there attributes to be diplayed in a dropdown menu per attribute. 基本上,我有一个客户希望所有这些属性都在每个属性的下拉菜单中显示。 For example Brands would have a dropdown to select a particular brand filter and the same for colors, sizes, etc. Here's the script that I used. 例如,“品牌”将具有一个下拉列表来选择特定的品牌过滤器,并且在颜色,尺寸等方面也是如此。这是我使用的脚本。

 <select onchange="setLocation(this.value)">
     <option value=""><?php echo 'Choose an Option...' ?></option>
     <?php foreach ($this->getItems() as $_item): ?>
         <option
            <?php if ($_item->getCount() > 0): ?>
            value="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?>
            <?php else: echo '>' . $_item->getLabel() ?>
            <?php endif; ?>
            (<?php echo $_item->getCount() ?>)
        </option>
    <?php endforeach ?>
    </select>

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM