Using magento layout files - is it possible to include a block, only if an admin setting is true.
Exactly like you can do using the ifconfig property when using action method="s开发者_开发知识库etTemplate".
Not directly. The ifconfig
mechanism is the only conditional like structure in the Layout Update XML system that ships with Magento.
If you're comfortable creating modules and custom blocks class though, you can achieve the results you want pretty easily.
Create a custom Block class that extends whatever block you're interested in conditionally adding.
Create a new
_toHtml
method in your class with the conditional logic you want. If the tests pass have your methodreturn parent::_toHtml
, otherwise have it return an empty string.
精彩评论