In Magento xml layut or config file we can write ifconfig as parameter in a tag to apply a condition like this
<action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled">
<label>Contact Us</label>
<url>contacts</url>
<title>Contact Us</title>
<prepare>true</prepare>
</action>
I was trying to find ifconfig alternative of this function
Mage::getStoreConfig($path,Mage::app()->getStore());
so that i can include store condition along with path in ifconfig. Any help will be appreciated.
There is no built in way to do that, mainly because the ifconfig
constraint is used for the current store. When calling Mage::getStroreConfig()
with only one parameter the current store is used as the second parameter. and the layout is loaded for the current store.
But if you insist, here is a possible idea on how to do it.
The action
tags in the layout are parsed and applied in this method Mage_Core_Model_Layout::_generateAction()
. This piece of code checks the ifconfig
attribute.
if (isset($node['ifconfig']) && ($configPath = (string)$node['ifconfig'])) {
if (!Mage::getStoreConfigFlag($configPath)) {
return $this;
}
}
You can override this method to allow an additional parameter for the store. So your xml code would look like this:
<action method="someMethod" ifconfig="some/config/path" store="2" />
Now change the code above that calls the action to this:
if (isset($node['ifconfig']) && ($configPath = (string)$node['ifconfig'])) {
if (isset($node['store'])){//check config setting for supplied store
if (!Mage::getStoreConfigFlag($configPath, $node['store'])) {
return $this;
}
}
else{//default behavior
if (!Mage::getStoreConfigFlag($configPath)) {
return $this;
}
}
}
Try Conditive Extended Ifconfig extension