0

I can't make my homepage to load a different template for my module.

I created a theme based on Magento/blank and created a module that changes navigation menu to nice looking vertical mega-menu and they all work just fine.

But I want to make my module to look different on the homepage. So I created one more template file: module-homepage.phtml

So now there are two template files in my app/code/frontend/Vendor/Module/view/frontend/templates folder

  1. module.phtml
  2. module-homepage.phtml

Then I created custom-homepage.xml file and put it here: app/design/frontend/Vendor/Theme_name/page_layout/ with the following content:

 <?xml version="1.0"?>
        <page layout="2columns-left" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

            <head>
                <!-- Add local resources -->
                <css src="css/whateverstyle.css"/>
            </head>
            <body>
                <referenceBlock name="block.name" template="Vendor_Module::module-homepage.phtml" />
            </body>
        </page>

I applied it and it did not work. Homepage loaded blank. Because it was page_configuration and NOT page_layout XML file.

Then I changed its contents to the following:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. 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="2columns-left"/>
    <referenceContainer name="page.top">

        <referenceBlock name="block.name" template="Vendor_Module::module-homepage.phtml"/>

    </referenceContainer>
</layout>

Still no result. Homepage loads fine now, but with no changes. My module-homepage.phtml is probably being ignored.

system.log gives me these 5 lines:

[2017-06-21 12:40:40] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_4c7461af04bb11fe209659d7147d2c579 and handles default, cms_index_index, cms_page_view, cms_index_index_id_home: Please correct the XML data and try again.  [] []

[2017-06-21 12:40:40] main.INFO: Cyclic dependency in merged layout for handle: 2columns-left [] []

[2017-06-21 12:40:40] main.INFO: Cyclic dependency in merged layout for handle: 2columns-left [] []

[2017-06-21 12:40:40] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_4cdabc34b90cd18ffdcfe81ef0f5a7189 and handles custom-homepage: Please correct the XML data and try again.  [] []

[2017-06-21 12:40:40] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_46f1b068ec7ccf4878f9284dd1137afd1 and handles catalog_product_prices: Please correct the XML data and try again.  [] []
  • PROBLEM SOLVED. It turned out that you must upload your custom layout in DESIGN in admin area, and not the xml files in template. – overjolted Jun 27 '17 at 10:02
0

PROBLEM SOLVED. It turned out that you must upload your custom layout in DESIGN in admin area, and not the xml files in template.

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.