开发者

Magento Layout - Include block only if admin setting is true

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.

  1. Create a custom Block class that extends whatever block you're interested in conditionally adding.

  2. Create a new _toHtml method in your class with the conditional logic you want. If the tests pass have your method return parent::_toHtml, otherwise have it return an empty string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜