5

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?

Mohit Kumar Arora
10.2k7 gold badges29 silver badges57 bronze badges
asked Jul 10, 2018 at 13:29
2
  • You created layout_page folder or page_layout folder ? Commented Jul 10, 2018 at 13:38
  • @PankajPareek I'm sorry. It's page_layout... but is not this the problem :( Commented Jul 10, 2018 at 13:48

2 Answers 2

3

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>
answered Jul 10, 2018 at 14:01
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>
answered Jul 10, 2018 at 14:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.