0

How to show the message box in Magento 2 (on the home page). message box working the whole site except for the home page.

enter image description here

0

open your Magento 2 theme's cms_index_index.xml file and update with below xml content to insert message block into Home page

File : cms_index_index.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
...........................
...........................
    <referenceContainer name="page.messages">
           <block class="Magento\Framework\View\Element\Template" name="ajax.message.placeholder" template="Magento_Theme::html/messages.phtml"/>
           <block class="Magento\Framework\View\Element\Messages" name="messages" as="messages" template="Magento_Theme::messages.phtml"/>
        </referenceContainer>
...........................
...........................
    </body>
</page>
0

try to create one message.phtml file in Magento_Theme/html/message.phtml, than add your code. in layout file - cms_index_index.xml inside body tag and add below code :

<referenceContainer name="page.messages">
        <block class="Magento\Framework\View\Element\Template" name="ajax.message.placeholder" template="Magento_Theme::html/messages.phtml"/>
        <block class="Magento\Framework\View\Element\Messages" name="messages" as="messages" template="Magento_Theme::messages.phtml"/>
</referenceContainer>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.