Chapters Close

Difference between attributes remove and display true|false in the layout

This article will help you to understand the basic difference between attributes remove and display true|false in Magento 2 layout.

Remove attribute

  • Allows to remove or cancel the removal of the element. When a container is removed, its child elements are removed as well.
  • The remove attribute is optional and its default value is false.
  • This implementation allows you to cancel the removal of a block or container in your layout by setting remove attribute value to true.
  • Possible values are true and false.

Example:

<referenceBlock name="block.name" remove="true" />

Display attribute

  • Allows you to disable rendering of a specific block or container with all its children (both set directly and by reference). The block’s/container’s and its children’ respective PHP objects are still generated and available for manipulation.
  • The display attribute is optional and its default value is true.
  • You are always able to overwrite this value in your layout. In the situation when remove value is true, the display attribute is ignored.
  • Possible values are true and false.

Example:

<referenceContainer name="container.name" display="false" />

Hope this detailed article served your purpose. Feel free to leave the comments below and contact us if you need any help to customize your Magento store.

Speak your Mind

Post a Comment

Got a question? Have a feedback? Please feel free to leave your ideas, opinions, and questions in the comments section of our post! ❤️

* This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Grow your online business like 4,407 subscribers

    * This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
    envelope

    Thank You!

    We are reviewing your submission, and will be in touch shortly.