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=”setTemplate”.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not directly. The
ifconfigmechanism 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
_toHtmlmethod 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.