1

I'm building a store responsively and for the top navigation on a mobile I have an option to "filter" which should only be shown on pages which are filterable, such as the search results page, the catalog pages.

This is just a link with an id which makes a siderbar slide in/out. But the link only needs to be shown if there's actually something to filter.

I've tried looking in to the Catalog_Block_Layer class and there are a couple of methods which I thought might work, but don't. Such as:

Mage::getSingleton('Mage_Catalog_Block_Layer')->canShowBlock()

and

Mage::getSingleton('Mage_Catalog_Block_Layer')->canShowOptions()

Any ideas how I can achieve this?

1 Answer 1

1

The methods in your question are not working because by the time you call them Mage_Catalog_Block_Layer might be not yet instantiated.

One dirty solution can be the following:

if (count(array_intersect($this->getLayout()->getUpdate()->getHandles(), array('catalog_category_layered', 'catalogsearch_result_index'))) {
    ...
}
1
  • I did think that would be the reason why it wasn't working because I was using it in the header. But your solution seems to work fine, thanks.
    – Karl
    Commented Apr 7, 2014 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.