简体   繁体   中英

Tweaking layered navigation in Magento

Im figured out about magento layered navigation. 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. 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:

$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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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