I created default.xml for my module. I want to inject block into header. I tried different ways like:
<referenceContainer name="header.container" before="-">
<block class="Vendor\Name\Block\Block" name="myname" template="Vendor_Name::block.phtml" />
</referenceContainer>
<referenceContainer name="header.container" before="-">
<block class="Vendor\Name\Block\Block" name="myname" template="Vendor_Name::block.phtml" />
</referenceContainer>
<referenceContainer name="header.wrapper">
<block class="Vendor\Name\Block\Block" name="myname" template="Vendor_Name::block.phtml" />
</referenceContainer>
....
But it still not working. Injection my block into body (if i use name="after.body.start" working ok.
I make sure that my Module will load after Theme
<sequence>
<module name="Smartwave_Porto"/>
</sequence>
But my block is still not visible or in some cases (when i use orher names) magento do not add my block to cointeriner but emptyfied this cointerner - display empty cointeriner.
What are the the best methods to debug what exactly is going on under the hood - if i want to trace whole process of creating HTML of HTML?
2 Answers 2
Please review below file.
Hope this will help you.
Thank you
-
Not so much, because i already tried <referenceContainer name="header.panel"><block /></referenceContainer> but no effec in my template.user88831– user888312020年05月01日 06:20:20 +00:00Commented May 1, 2020 at 6:20
-
Right now i see that on new magento installation with luma theme this works. So there must be something that affect displaying of my block either in custom Theme or in one of Module that is installed in my magento instance. Maybe this "Mgt Developer Tool' will help to find the problem.user88831– user888312020年05月01日 07:09:42 +00:00Commented May 1, 2020 at 7:09
In response to your other question, I would recommend Mgt Developer Toolbar (https://www.mgt-commerce.com/documentation/magento2-mgt-developer-toolbar).
This will let you inspect all the blocks/handles etc that are getting outputted to your page.
-
I: installed mgt. I get block name from it and use like <referenceContainer name="porto_header" > <Block... atfer this whole porto_header disappear now.user88831– user888312020年05月04日 06:06:01 +00:00Commented May 4, 2020 at 6:06