I'm playing around with custom theming, but I'm kinda stuck and I find that the front end dev guide becomes pretty unclear after you activate your theme.

So I created my own theme and activated it etc, which is nice. But now I want to create my own homepage for example, or I want to create a search result page.

How do I do this correctly?

From what I've seen I have to create my own modules per block? So for example, Hero-area_Module, content_Module, footer_module? or am I completely wrong?

I find that Mangento is so much more frustrating the Wordpress for example, so if you have really good must read tutorials (that go beyond creating a template and activating it, then doing nothing with it). feel free to link them.



I'm unable to comment on your post so I'm posting as my "answer".

There already is a homepage (CMS page) and search result page. You can overwrite the xml/phtml files to add/remove blocks. Similar to how you would create a child theme in WP.

So for instance, for the homepage, I wanted to add a 2nd search function. If I added that to the /theme/layout/default.xml file, it would be displayed on all pages (which I don't want).

So what I had to do was copy module-cms/view/frontend/layout/cms_index_index.xml into my own theme Magento_Cms/layout/cms_index_index.xmland add a block to the referenceContainer I want it placed in.

In the default.xml file, there is a referenceContainer name="page.top", that is where I want the 2nd search function to go.

So what I would need to do with the xml file I just copied into my theme, is add

<referenceContainer name="page.top">
    <block class="Magento\Framework\View\Element\Template" name="top.search.home" as="topSearchHome" template="Magento_Search::form.mini.homepage.phtml" after="breadcrumbs"/>

When customizing phtml files, you can also reference cms static blocks like so:

<div class="footer-blocks transition-all">
   <div class="block-column-1 transition-all"><?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('footer_equipment_links')->toHtml();?></div>
   <div class="block-column-2 transition-all"><?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('footer_support_links')->toHtml();?></div>
   <div class="block-column-3 transition-all"><?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('footer_company_links')->toHtml();?></div>
   <div class="block-column-4 transition-all"><?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('footer_contact_links')->toHtml();?></div>
   <div class="block-column-5 transition-all"><?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('footer_cta')->toHtml();?></div>

Similar to how you would register widgets in functions.php in WP and then echoing it in the php files in your theme.

I told my coworker who is new to Magento (I'm fairly new as well), is to code out say the footer piece like how you normally would in html. Whatever, piece you want as static blocks, you take that html code and create the static block in the cms. And in the phtml, you replace the content by echoing the block ID.

Let me know if this is what you were referring to.

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.