2

I created a theme in magento 2 and in that theme i created a new page layout.

I can see the page layout in my magento admin dashboard.

So i assigned the page layout to my homepage.

But now my home page is coming blank.

My theme structure:

My theme Code

Registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/Magento/DrugTheme',
    __DIR__
);

Theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
     <title>Magestore Simple Theme</title> <!-- your theme's name -->
     <parent>Magento/luma</parent> <!-- the parent theme, in case your theme inherits from an existing theme -->
     <media>
         <preview_image>media/preview.jpg</preview_image> <!-- the path to your theme's preview image -->
     </media>
 </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="1column">
    <layout id="test">
        <label translate="true">Full Layout</label>
    </layout>
</page_layouts>

And finally my test.xml (My page layout file)

<?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="2columns-left"/>
   <referenceContainer name="page.wrapper">
       <referenceBlock name="breadcrumbs" remove="true"/>
   </referenceContainer>
   <referenceContainer name="columns">
       <referenceContainer name="div.sidebar.main" remove="true"/>
   </referenceContainer>
</layout>

1 Answer 1

0

Try some other vendor name in registration.php

'frontend/Vendor/DrugTheme'

Create a composer.json like -

{
 "name": "magento/theme-frontend-yourtheme", //declare your theme
 "description": "N/A",
 "require": {
 "php": "~5.5.0|~5.6.0|~7.0.0",
 "magento/theme-frontend-luma": "100.0.*", //blank is my parent theme here
 "magento/framework": "100.0.*"
 },
 "type": "magento2-theme",
 "version": "100.0.5",
 "license": [
 "OSL-3.0",
 "AFL-3.0"
 ],
 "autoload": {
 "files": [
 "registration.php"
 ]
 }
}

I am not sure there is any layouts.xml

You should add default.xml and default_head_blocks.xml in Magento_Theme/layout

Your ideal structure should be like -

https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/themes/theme-create.html

Edit-

For custom layout try creating a module, and place the layouts.xml and test.xml in there.

Check link - https://webkul.com/blog/how-to-create-custom-layout-page/

4
  • Tried ,still not working Feb 24, 2020 at 9:20
  • It will be great if you can share the complete directory structure, what you tried and what is not working.
    – Gagan
    Feb 24, 2020 at 9:43
  • My themes public repo : github.com/akshaynaiksjinnovation/Theme Feb 24, 2020 at 10:05
  • I have update my answer, with new reference link. You can try creating a module and add layout to that like reference link.
    – Gagan
    Feb 24, 2020 at 10:18

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.