0

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

0

Please review below file.

https://github.com/magento/magento2/blob/2.4-develop/app/design/frontend/Magento/luma/Magento_Theme/layout/default.xml

Hope this will help you.

Thank you

2
  • Not so much, because i already tried <referenceContainer name="header.panel"><block /></referenceContainer> but no effec in my template.
    – user88831
    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
    May 1, 2020 at 7:09
0

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.

1
  • 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
    May 4, 2020 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.