2

I have created a cms block and using widget added inside header page container, now I want to remove that block from only home page.

How can i achieve this?

Widget screenshot to display block

enter image description here

asked Mar 27, 2019 at 6:59

5 Answers 5

1

Go to

Admin -> Content -> Pages -> Edit CMS page (which you want to update) -> Design -> Layout Update XML

And then, post this below code in that field

<referenceContainer name="content.top">
 <referenceBlock name="form.popup.subscribe" remove="true"/>
</referenceContainer>

You can set name of referenceContainer and referenceBlock name which you want to remove.

Hope, It will helpful for you !!

answered Sep 20, 2019 at 11:00
0

From Layout file:

Goto app/design/frontend/[VendorTheme]/[ThemeName]/Magento_Cms/layout/cms_index_index.xml and add below code. BlockName will be the name of block which you want to delete.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <body>
 <!-- add this code for remove block -->
 <referenceBlock name="BlockName" remove="true"/>
 </body>
 </page>
answered Mar 27, 2019 at 7:05
1
  • I implement this but not working Commented Mar 27, 2019 at 8:43
0

Into the CMS home page, Design -> Layout Update XML

<referenceBlock name="BlockName" remove="true"/>

save the cms page and clear the cache.

without xml you want to hide them using css display none.

answered Mar 27, 2019 at 7:22
1
  • i get following error 'Please correct the XML data and try again. Element 'referenceBlock': This element is not expected. Expected is one of ( referenceContainer, container, update, move, head, body ). Line: 1' Commented Mar 27, 2019 at 8:35
0

create below file

app/design/frontend/name/example/Magento_CMS/layout/cms_index_index.xml

<referenceBlock name="block_name" remove="true"/>

add below code and add your static block_name Example:

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
 <body>
 <referenceBlock name="block_name" remove="true"/>
 </body>
</page>
answered Mar 27, 2019 at 7:28
1
  • I implement this but not working Commented Mar 27, 2019 at 8:43
0

It would be best if you put the following code:

<referenceBlock name="block_name" remove="true"/>

in the Design>> Layout Update XML section of your CMS Home page in the admin panel.

After that, you just need to flush Magento's cache.

Since Magento provides to update the layout of CMS pages from the backend, there is no need to do it using the layout files.

Update: widget xml generated on save widget

I hope it is clear.

answered Mar 27, 2019 at 7:27
7
  • i get following error 'Please correct the XML data and try again. Element 'referenceBlock': This element is not expected. Expected is one of ( referenceContainer, container, update, move, head, body ). Line: 1' Commented Mar 27, 2019 at 8:33
  • Also, If i add block id in name will it work Commented Mar 27, 2019 at 8:35
  • @Arjun, you are right. I noticed your point now. This is happening because while adding a widget to the pages, Magento generates the block name dynamically. Commented Mar 27, 2019 at 11:37
  • When we try to print the generated XML after saving the widget instance, we get the block name as a random string. Please check the screenshot in my answer's update. Commented Mar 27, 2019 at 11:59
  • ok i got your point so what do you suggest how can i remove this block only on home page or else i should remove widget Commented Mar 27, 2019 at 12:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.