1

I am creating a magento theme based on the magento/blank theme, and I am trying to change the opening div's class from page-wrapper to container.

Attempt
I tried to create a file in /app/code/myvendor/theme/Theme/view/layout/override/base/empty.xml with the intention it would replace the file in /app/code/Magento/Theme/view/base/page_layout/empty.xml allowing me to change the class but nothing happened.

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <container name="root">
        <container name="after.body.start" as="after.body.start" before="-" label="Page Top"/>
        <container name="page.wrapper" as="page_wrapper" htmlTag="div" htmlClass="container">
            <container name="global.notices" as="global_notices" before="-"/>
            <container name="main.content" htmlTag="main" htmlId="maincontent" htmlClass="page-main">
                <container name="columns.top" label="Before Main Columns"/>
                <container name="columns" htmlTag="div" htmlClass="columns">
                    <container name="main" label="Main Content Container" htmlTag="div" htmlClass="column main"/>
                </container>
            </container>
            <container name="page.bottom.container" as="page_bottom_container" label="Before Page Footer Container" after="main.content" htmlTag="div" htmlClass="page-bottom"/>
            <container name="before.body.end" as="before_body_end" after="-" label="Page Bottom"/>
        </container>
    </container>
</layout>

How can I achieve this? Thanks in advance!

8
  • You have to overrider xml file inside your custom theme to make effect of changes Feb 13, 2017 at 11:23
  • Your path is wrong if you want to override into theme then your file location should be app/design/frontend/Vendorname/themename/Magento_Theme/view/layout/override/base/empty.xml Feb 13, 2017 at 11:24
  • @ManthanDave Thanks, I have just tried creating a file: /app/design/frontend/myvendor/mytheme/Magento_Theme/view/layout/override/base/empty.xml with the same contents as what I put above, but the class isnt changing on the website. The only way so far I have managed to achieve this is by editing the original base file in Magento's files which of course is bad practise. Any more ideas?
    – Hunter
    Feb 13, 2017 at 11:30
  • @LeonHunter you have created custom theme right ? so first verify that your custom theme is active or not ? you don't need to edit base file. Feb 13, 2017 at 11:31
  • @ManthanDave yes, I have created the theme and can verify it is working, I have replaced the theme logo using a different xml file (layout.xml)
    – Hunter
    Feb 13, 2017 at 11:33

4 Answers 4

3

I just placed the empty.xml in the following location and it worked:

app/design/frontend/myvendor/mytheme/Magento_Theme/page_layout/empty.xml

2
  • I can't replicate the solution. I change the theme in the admin. I can confirm other changes do apply, like the less/css changes. I tried all the posible options in this page. Here a list of files I'v tested (they all inside my theme folder) - ./Magento_Theme/view/layout/override/base/empty.xml - ./Magento_Theme/view/layout/base/empty.xml - ./Magento_Theme/view/frontend/layout/page_layout/empty.xml - ./Magento_Theme/view/frontend/page_layout/empty.xml - ./Magento_Theme/view/base/page_layout/empty.xml - ./Magento_Theme/page_layout/empty.xml But none of them worked.
    – StR
    Nov 9, 2018 at 12:51
  • 2.3 = /app/design/frontend/<vendor>/<module>/Magento_Theme/page_layout/empty.xml
    – zigojacko
    Apr 16, 2020 at 10:11
1

you have to keep your content at below location,

app/design/frontend/myvendor/mytheme/Magento_Theme/view/frontend/page_layout/empty.xml

now add your code,

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <container name="root">
        <container name="after.body.start" as="after.body.start" before="-" label="Page Top"/>
        <container name="page.wrapper" as="page_wrapper" htmlTag="div" htmlClass="container">
            <container name="global.notices" as="global_notices" before="-"/>
            <container name="main.content" htmlTag="main" htmlId="maincontent" htmlClass="page-main">
                <container name="columns.top" label="Before Main Columns"/>
                <container name="columns" htmlTag="div" htmlClass="columns">
                    <container name="main" label="Main Content Container" htmlTag="div" htmlClass="column main"/>
                </container>
            </container>
            <container name="page.bottom.container" as="page_bottom_container" label="Before Page Footer Container" after="main.content" htmlTag="div" htmlClass="page-bottom"/>
            <container name="before.body.end" as="before_body_end" after="-" label="Page Bottom"/>
        </container>
    </container>
</layout>

Run php bin/magento cache:clean command

8
  • Thanks for the reply, I have just tried creating /app/design/frontend/myvendor/mytheme/Magento_Theme/view/frontend/layout/page_layout/empty.xml but it is still not changing the page. Its like this file is being ignored by the system?
    – Hunter
    Feb 13, 2017 at 11:39
  • Have you clean cache? also clear browser cache. Feb 13, 2017 at 11:40
  • yeah I just cleaned Magento cache using php bin/magento cache:clean and also my browser cache and the changes still don't take affect.
    – Hunter
    Feb 13, 2017 at 11:45
  • you have to give below location, app/design/frontend/myvendor/mytheme/Magento_Theme/view/fro‌​ntend/page_la‌​yout/empty.xml remove layout folder. Its typomistake for layout folder Feb 13, 2017 at 11:49
  • Have you check using remove layout folder from Magento_Theme/page_layout? Feb 13, 2017 at 11:54
1

I found a solution for this, I faced the same issue for updating empty.xml file from Magento_Theme/view/base/page_layout.

I have created a custom layout inside my /<vendor>/<theme>/<Magento_Theme>/layouts.xml

<?xml version="1.0" encoding="UTF-8"?>
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="custom-layout">
        <label translate="true">Custom Layout</label>
    </layout>
</page_layouts>

Then I have created a layout file inside /<vendor>/<theme>/<Magento_Theme>/page_layout/custom-layout.xml

Then I have update the update handler like this

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <update handle="custom"/>
    <referenceContainer name="page.wrapper">
        <container name="header.container" as="header_container" label="Page Header Container" htmlTag="header" htmlClass="page-header" before="main.content"/>
        <container name="page.top" as="page_top" label="After Page Header" after="header.container"/>
        <container name="footer-container" as="footer" before="before.body.end" label="Page Footer Container" htmlTag="footer" htmlClass="page-footer"/>
    </referenceContainer>
</layout>

Then I have create a custom.xml file inside same folder /<vendor>/<theme>/<Magento_Theme>/page_layout/custom.xml

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <container name="root">
        <container name="after.body.start" as="after.body.start" before="-" label="Page Top"/>
        <container name="page.wrapper" as="page_wrapper" htmlTag="div" htmlClass="page-wrapper">
            <container name="global.notices" as="global_notices" before="-"/>
            <container name="main.content" htmlTag="main" htmlId="mycontent" htmlClass="mycontent">
                <container name="columns.top" label="Before Main Columns"/>
                <container name="columns" htmlTag="div" htmlClass="mycontent">
                    <container name="main" label="Main Content Container" htmlTag="div" htmlClass="mycontent"/>
                </container>
            </container>
            <container name="page.bottom.container" as="page_bottom_container" label="Before Page Footer Container" after="main.content" htmlTag="div" htmlClass="page-bottom"/>
            <container name="before.body.end" as="before_body_end" after="-" label="Page Bottom"/>
        </container>
    </container>
</layout>

Now I am able to update base layout file as I want.

Hope this will help.

0

okay so you have issue with the location.

You are overriding directly view not layout. so your file location should be below :

app/design/frontend/myvendor/theme/Magento_Theme/view/base/page_layout/empty.xml

Then add your code :

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <container name="root">
        <container name="after.body.start" as="after.body.start" before="-" label="Page Top"/>
        <container name="page.wrapper" as="page_wrapper" htmlTag="div" htmlClass="container">
            <container name="global.notices" as="global_notices" before="-"/>
            <container name="main.content" htmlTag="main" htmlId="maincontent" htmlClass="page-main">
                <container name="columns.top" label="Before Main Columns"/>
                <container name="columns" htmlTag="div" htmlClass="columns">
                    <container name="main" label="Main Content Container" htmlTag="div" htmlClass="column main"/>
                </container>
            </container>
            <container name="page.bottom.container" as="page_bottom_container" label="Before Page Footer Container" after="main.content" htmlTag="div" htmlClass="page-bottom"/>
            <container name="before.body.end" as="before_body_end" after="-" label="Page Bottom"/>
        </container>
    </container>
</layout>

Clear the cache and check it will works !!

2
  • Cleared the cache and tried putting the file in app/design/frontend/myvendor/theme/Magento_Theme/view/base/page_layout/empty.xml and still not working.
    – Hunter
    Feb 13, 2017 at 12:07
  • 2.3 = /app/design/frontend/<vendor>/<module>/Magento_Theme/page_layout/empty.xml
    – zigojacko
    Apr 16, 2020 at 10:12

Your Answer

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

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