I have written a module that has a settings page in the backend. The Module overrides a layout.xml file and uses a modified template by editing my own template path


in this line of the layout file:

<block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="form/register.phtml">

But I would like to override this layout file only if the backend settings for this module is set to enabled.

I know I can add some code in the template I override to check for the setting before doing my modifications, but is there another way?


you can use ifconfig attribute to check admin setting,

<block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="form/register.phtml" ifconfig="passyour/config/value">

For your reference in wishlist module,

 <block class="Magento\Framework\View\Element\Html\Link\Current" ifconfig="wishlist/general/active" name="customer-account-navigation-wish-list-link">

Add following code to view template only if your module is enabled from backend :

<action method="setTemplate" ifconfig="tagname/general/active">
<block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="form/register.phtml">

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.