This article will help you to understand, compare 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" />To compare attributes remove and display, remember that remove eliminates the block from rendering, while display only controls its visibility during output.
Hope this detailed article served your purpose. Feel free to leave your comments below, and contact us if you need any help to customize your Magento store.
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! ❤️