Quantcast
Channel: Webkul Blog
Viewing all articles
Browse latest Browse all 5537

Remove blocks or containers from layout magento2

$
0
0

Today i am explaining how to remove a block or container called by layout files.

Firstly you need to create layout file for the same controller.
for example : catalog_category_view.xml

Now add the line in your layout file:

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

in this, you can use referenceBlock for the blocks, and referenceContainer for the containers.
name, is the name of the block or container which you want to remove.
remove, is set to true to remove.

your file will be like this:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
	<body>
		<referenceBlock name="content" remove="true" />
	</body>
</page>

After flushing cache, the whole content container will get removed from category page.

Hope, this will helps you adding functionality in your module.

Thank you.


Viewing all articles
Browse latest Browse all 5537

Trending Articles