0

i want to add a custom side bar phtml file in the home page that would show specific categories. i couldn't find a specific layout or template file for the homepage. any ideas?

0

Magento 2: How to override Luma Theme Home Page

here you can find the details hope this helps if helps accept as answer

  • did not help at all – Kames Guen Nov 16 '19 at 20:59
0

to answer my question: first, the homepage like many other pages(ex: footer) are CMS pages, meaning that they are created and used by the admin, meaning that they don't have a particular layout or template or block files. 1-if you want to change the layout to 2-columns-left for example, you can either do it the admin panel or like I did edit the row in the database with installData:

$setup->startSetup();
$setup->updateTableRow('cms_page', 'page_id', '2', 'page_layout', '2columns-left');
$setup->endSetup();

2- next you want to create your sidebar template and it's the corresponding block in your custom module. 3- finally in your custom theme in

vendore/theme/Magento_Cms/layout/cms_index_index.xml

add this:

 <body>
        <referenceContainer name="page.wrapper">

            <referenceContainer name="columns">
                <container name="div.sidebar.main" htmlTag="div" htmlClass="sidebar sidebar-main" before="main">
                    <container name="sidebar.main" as="sidebar_main" label="Sidebar Main">
                        <block class="vendore\module\Block\SideBar"
                               template="vendore_module::side_menu.phtml"/>
                    </container>
                </container>
            </referenceContainer>
        </referenceContainer>
    </body>

and like this you can a custom side bar in your home page

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.