3

I've create a custom layout for static page into Magento 2.

app/design/frontend/VENDOR/THEME/Magento_Cms/layouts.xml

<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="customer-service">
        <label translate="true">customer-service</label>
    </layout>
</page_layouts>

app/design/frontend/VENDOR/THEME/Magento_Cms/page_layout/customer-service-layout.xml

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
<update handle="1column"/>
<referenceContainer name="content">
</referenceContainer></layout>

Now I can select my layout into Design ->Layout of my Static Page but into my frontend, I have a blank white page.

Information:

  1. It doesn't even work if I put my layout code in the Magento_Theme module
  2. If I select another layout of my page everything works properly.
  3. The frontend page doesn't go to 404 page but an empty page with class cms-page-view page-layout-customer-service in the body tag

Can you help me, please?

  • You created layout_page folder or page_layout folder ? – Pankaj Pareek Jul 10 '18 at 13:38
  • @PankajPareek I'm sorry. It's page_layout... but is not this the problem :( – markpes Jul 10 '18 at 13:48
3

Add Code

app/design/frontend/VENDOR/THEME/Magento_Theme/layouts.xml

<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="customer-service">
        <label translate="true">Customer Service</label>
    </layout>
</page_layouts>

Create New File under

app/design/frontend/VENDOR/THEME/Magento_Theme/page_layout/customer-service.xml

<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"/>
        <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> 
    <referenceContainer name="content">

    </referenceContainer> 
</layout>
0

You need to create the xml under page_layout with name customer-service.xml not customer-service-layout.xml:

Content for customer-service.xml

<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <update handle="1column"/>
    <referenceContainer name="content">
    </referenceContainer>
</layout>

Name of the xml always the {id}.xml of your layouts.xml like below(your id is customer-service thats why it should be customer-service.xml):

<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="customer-service">
        <label translate="true">customer-service</label>
    </layout>
</page_layouts>

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.