I have some lines of PHP code that will prevent certain attribute filters to be shown within the layered navigation block (i.e. Price and Category). This way I need to add all the filters that I don't want to be shown by hand which takes a lot of time and isn't the best solution.
What I want is the filter attributes "Price" and "Category" to be shown and if the filtername is different, don't display that filter at all. This way the price and category filters are always displayed, and the other filters get hidden. I don't have to add all the filters by hand which I do not want to show up in the list.
My question is, what needs to change within the PHP code to make it work the way I just described?
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<?php if($_filter->getName() != "Price" AND $_filter->getName() != "Category"): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
Ah I see. Funnily enough I was working on something virtually identical yesterday and this works for me (I mean to the change to the IF statement);
<?php foreach ($_filters as $_filter): ?>
<?php if (Mage::helper('catalog')->__($_filter->getName()) == 'Price' || Mage::helper('catalog')->__($_filter->getName()) == 'Category'): ?>
<dt><?php echo Mage::helper('catalog')->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endforeach; ?>
Hopefully it will work for you too.