3

Hi I am having multi website, I want to remove entire footer from website id 3. here is my xml file

Ubertheme/shop/Magento_Theme/layout/default.xml

here added the code.

  <referenceContainer name="footer-container" remove="true" />

This is removing footer from all websites. How to make it for only website Id 3. Can I Get help? Thank you in advance

3

You can use this below process:

Create a unique layout handle for that website only. Like website_3 and use the observer event layout_load_before

Observer code

class LayoutLoadBefore implements \Magento\Framework\Event\ObserverInterface {

    /**
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    private $storeManager;

    public function __construct(
        \Magento\Store\Model\StoreManagerInterface $storeManager
    ) {
        $this->storeManager = $storeManager;
    }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
       if ($this->storeManager->getStore()->getWebsiteId() == 3) {
           $layout = $observer->getEvent()->getLayout();

           $handlecode ='website_'.$this->storeManager->getStore()->getWebsiteId();
           $layout->getUpdate()->addHandle($handlecode);
        }

        return $this;
    }

}

Layout code for that file

app/code/{Vendorname}/{Module Name}/view/frontend/layout/website_3.xml

<?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>
        <referenceContainer name="footer-container" remove="true" />
    </body>
</page>
1
  • this is working like charm. Thank you so much for answer @Ritesh Santra – Praveen Negimani Aug 11 '20 at 7:18

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.