Skip to main content
Tweeted twitter.com/StackMagento/status/751430382852141056
added 4 characters in body
Source Link

I'm having trouble creating a custom layout. I have successfully created a layout called "home_page.xml"home_page.xml which is a copy of the default 1column layout.

I have selected this layout for my home page, but can't seem to add any content to it. Am I limited to only adding containers to the home_page.xmlhome_page.xml file? No HTML that I add will appear on my home page.

I've been reading on how to create and reference containers but it doesn't make a lot of sense, and I'm not sure what files I need to create in order to do so.

Here is my home_page.xmlhome_page.xml file:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 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">
    <update handle="empty"/>
    <referenceContainer name="page.wrapper">
        <container name="header.container" as="header_container" label="Page Header Container"  htmlTag="header" htmlClass="page-header" before="main.content"/>
        
        <div id="test123"><p>This is a test</p></div>
        
        <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>

The div doesn't show up. I can successfully remove the header and footer containers however, so I know that the layout file is working successfully.

My ultimate goal is to add a full width content slider directly under the header on the home page. Any help is extremely appreciated. I've been searching around for a couple days and have run out of new content to study.

I'm having trouble creating a custom layout. I have successfully created a layout called "home_page.xml" which is a copy of the default 1column layout.

I have selected this layout for my home page, but can't seem to add any content to it. Am I limited to only adding containers to the home_page.xml file? No HTML that I add will appear on my home page.

I've been reading on how to create and reference containers but it doesn't make a lot of sense, and I'm not sure what files I need to create in order to do so.

Here is my home_page.xml file:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 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">
    <update handle="empty"/>
    <referenceContainer name="page.wrapper">
        <container name="header.container" as="header_container" label="Page Header Container"  htmlTag="header" htmlClass="page-header" before="main.content"/>
        
        <div id="test123"><p>This is a test</p></div>
        
        <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>

The div doesn't show up. I can successfully remove the header and footer containers however, so I know that the layout file is working successfully.

My ultimate goal is to add a full width content slider directly under the header on the home page. Any help is extremely appreciated. I've been searching around for a couple days and have run out of new content to study.

I'm having trouble creating a custom layout. I have successfully created a layout called home_page.xml which is a copy of the default 1column layout.

I have selected this layout for my home page, but can't seem to add any content to it. Am I limited to only adding containers to the home_page.xml file? No HTML that I add will appear on my home page.

I've been reading on how to create and reference containers but it doesn't make a lot of sense, and I'm not sure what files I need to create in order to do so.

Here is my home_page.xml file:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 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">
    <update handle="empty"/>
    <referenceContainer name="page.wrapper">
        <container name="header.container" as="header_container" label="Page Header Container"  htmlTag="header" htmlClass="page-header" before="main.content"/>
        
        <div id="test123"><p>This is a test</p></div>
        
        <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>

The div doesn't show up. I can successfully remove the header and footer containers however, so I know that the layout file is working successfully.

My ultimate goal is to add a full width content slider directly under the header on the home page. Any help is extremely appreciated. I've been searching around for a couple days and have run out of new content to study.

Source Link
David
  • 51
  • 1
  • 1
  • 4

Magento 2: Creating a custom layout

I'm having trouble creating a custom layout. I have successfully created a layout called "home_page.xml" which is a copy of the default 1column layout.

I have selected this layout for my home page, but can't seem to add any content to it. Am I limited to only adding containers to the home_page.xml file? No HTML that I add will appear on my home page.

I've been reading on how to create and reference containers but it doesn't make a lot of sense, and I'm not sure what files I need to create in order to do so.

Here is my home_page.xml file:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 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">
    <update handle="empty"/>
    <referenceContainer name="page.wrapper">
        <container name="header.container" as="header_container" label="Page Header Container"  htmlTag="header" htmlClass="page-header" before="main.content"/>
        
        <div id="test123"><p>This is a test</p></div>
        
        <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>

The div doesn't show up. I can successfully remove the header and footer containers however, so I know that the layout file is working successfully.

My ultimate goal is to add a full width content slider directly under the header on the home page. Any help is extremely appreciated. I've been searching around for a couple days and have run out of new content to study.