Please help me understand layouts…


I’m having a real struggle with the concepts of layouts, I’ve done a few courses and read an absurd amount of blog posts, but still get stuck on some basics.

So for example I am trying to output CMS static blocks into the footer.

In app/design/frontend/MyCompany/MyTheme/Magento_Theme/layout/default.xml I have:

<referenceContainer name="footer" htmlClass="footer-content container"> <container name="" htmlTag="div" htmlClass="footer-block"> <block class="MagentoCmsBlockBlock" name=""> <arguments> <argument name="block_id" xsi:type="string">footer_block_one</argument> </arguments> </block> </container> 

<!– more blocks –>


Which does render the content from my CMS block ‘footer_block_one’, which is all well and good. But when I want to add more blocks in the same way, it ends up rendering them all out, and I cannot for the life of me find the .phtml file it is using.

I want to wrap each of the blocks within their own specific divs and have more control over the rendering out of the content, but it seems to simply just output it out as if by magic.

I have seen blog posts suggesting the following:

<?php echo $this->getLayout() ->createBlock('MagentoCmsBlockBlock') ->setBlockId('footer_block_one') ->toHtml(); ?> 


But it *feels* like the blocks should be passed through the layout. Could someone please point me in the right direction?

Many thanks

submitted by /u/Spirited_Refuse_3723
[link] [comments]