2

i know this question is already here.But i have tried all things. And nothing works for me.i need help, i am new to magento i have created a custom theme as default theme. Now i am trying to create a custom page template like app\design\frontend\accu\accu-theme\magento_theme and create the layout like

app\design\frontend\sample\sample-theme\magento_theme\page_layout\custom_home.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="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> </layout>

app\design\frontend\accu\accu-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_home"> <label translate="true">Custom Home</label> </layout> </page_layouts>

this is my code. In my admin panel Content->Pages in Home-Page not showing the custom-home page. Any one help me.

3 Answers 3

2

move app\design\frontend\sample\sample-theme\magento_theme\page_layout\custom_home.xml

to

app\design\frontend\accu\accu-theme\Magento_Theme\page_layout\custom_home.xml

in below, rename magento_theme to Magento_Theme

app\design\frontend\accu\accu-theme\magento_theme\layouts.xml

to

app\design\frontend\accu\accu-theme\Magento_Theme\layouts.xml

Else everything looks perfect.

Feel free for any query

======EDIT ============

update app\design\frontend\accu\accu-theme\Magento_Theme\page_layout\custom_home.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="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"/>

          <referenceContainer name="content"> <block class="Magento\Framework\View\Element\Template" name="test" output="toHtml" template="homepage.phtml"/> </referenceContainer>

          <container name="footer-container" as="footer" before="before.body.end" label="Page Footer Container" htmlTag="footer" htmlClass="page-footer" />
      </referenceContainer>
  </layout>
13
  • its it working fine
    – Ravi Kumar
    Commented Apr 10, 2017 at 6:45
  • now i need to add my homepage.phtml file into the home page custom design
    – Ravi Kumar
    Commented Apr 10, 2017 at 6:46
  • may I know for what purpose you want to add homepage.phtml Commented Apr 10, 2017 at 7:06
  • i need create the custom page design
    – Ravi Kumar
    Commented Apr 10, 2017 at 7:14
  • i am new to magento i need to create e-commerce web site using magent,i dont know how to work in magento
    – Ravi Kumar
    Commented Apr 10, 2017 at 7:15
0

Pleaser refer to this link: https://www.mageplaza.com/kb/how-to-add-a-new-cms-page-magento-2.html

You can create a custom homepage using cms page. In that link has the same idea on how to set it as your default homepage.

I hope this will help you. Thanks

1
  • its working. But i need to create the custom template like above
    – Ravi Kumar
    Commented Apr 10, 2017 at 6:30
0

For that you should create page layout folder in the directory of your Magento theme where you copy a file with custom template. In that file you assign the appearance of the page. As a base file you can use any of predefined (for example app/code/Magento/Theme/view/frontend/page_layout/1column.xml).The next step is going to be layouts.xml file creation in Magento Theme directory of your theme. Id attribute of layout tag should correspond to name of the page template file you previously created, and the content of label tag defines the template name in admin panel of the website. It’s better to create a new CMS page for the custom homepage. In order to do that just navigate to Content> Elements> Pages and click Add New Page button. Further it’s necessary to assign previously created template to this page. Just navigate to Design tab and choose the template in the Layout drop-down. So after you created a new CMS page and assigned the required template to it, you should assign this page as a Homepage for a certain store. Just navigate to Stores> Settings> Configuration, then in the left sidebar choose General Web and open the Default Pages tab. And the next step you should do is to select the webstore where you want the homepage to be changed. Next in the CMS Home Page drop-down list select the page you want to make Home Page for the certain store. Don’t forget to save all changes and flush the website cache.

here you can find the description of this process: https://belvg.com/blog/creating-a-custom-homepage-template-in-magento-2-1-5.html

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.