Chapters Close

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

Jul 7th, 2018 1 min to read

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" />
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,521 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.