1

I'm trying to force Magento to display a certain block only when a configuration condition is met. I was trying to use an ifconfig attribute on block declaration but this does not seem to work:

<reference name="left">
<block type="catalog/navigation" name="catalog.navigation.left.drilldown" as="left_navigation_drilldown" before="-" template="catalog/navigation/left/drilldown.phtml" ifconfig="catalog/side_navigation/enabled" />
(...)
</reference>
Sadly block is always displayed, even if catalog/side_navigation/enabled is set to false. I've seen that it was done in the same way in rss.xml for rss block. Yet it does not work for me.

I was trying method with helper presented by Alan Storm. Still no luck.

I know how to do it in way around but I would really like to use this very simple technique.

Community
  • 1
  • 1
Ventus
  • 2,482
  • 4
  • 35
  • 41

1 Answers1

4

ifconfig will only work on an action xml element, not ony block element, here an example:

<reference name="footer_links">
   <action method="addLink" translate="label title" module="catalog" ifconfig="catalog/seo/site_map"><label>Site Map</label><url helper="catalog/map/getCategoryUrl" /><title>Site Map</title></action>
</reference>
Sylvain Rayé
  • 2,456
  • 16
  • 23
  • Which is sad :/ oh well, you can always make it your way by rewriting Magento class, I guess. Thanks anyways – Ventus Mar 08 '12 at 11:14
  • In your case, you can still overwrite the catalog navigation block and set in the method _toHtml() the condition `if(Mage::getStoreConfig('catalog/side_navigation/enabled')) { return;} else return parent::_toHtml();` or in the template drilldown.phtml itself – Sylvain Rayé Mar 08 '12 at 12:08
  • Sure, this is the way around I have mentioned in my post – Ventus Mar 08 '12 at 12:16
  • Can I declare a block without template and then leverage the "setTemplate" action to implement the "ifconfig" attribute? – ermannob Jun 06 '14 at 07:44