5

What is the use of ifconfig tag inside the block tag in a layout xml file? What purpose does it serve?

6

The use of ifconfig is for condition which is coming from system config values. The value of this will be 0 and 1(boolean). According to that value block will be rendered. e.g.

<block ifconfig="custom_quickview/general/enable" class="Magento\Catalog\Block\Product\View" after="product.info.addtocart" name="goto.product" as="goto.product" template="Custom_Quickview::gotoproduct.phtml"/>

In this case if under system config custom_quickview/general/enable == 1 then only this block will be rendered else not.

  • @YDF Welcome. Happy Coding! – Sukumar Gorai Sep 10 '18 at 9:14
5

The ifconfig attribute allows you to specify a path to Magento's configuration (e.g. dev/log/active) that will be evaluated as a boolean value (using Mage::getStoreConfigFlag()). If this configuration option is set to true the action method will be called, the block will be created or the content of the reference will be evaluated.

2

Basically it's a condition in that block to render it or not, this condition you will set it in Admin->Stores->Configuration->All that config boolean fields and it comes in this format:

ifconfig="section/group/field"

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.