This post assumes the reader is familiar with Magento 2 modules and how they work. If not, it is highly recommended to read the documentation first. All files mentioned below must be placed inside a module.
In order to add a custom layout handle to category page, a (basic) Magento 2 module with these additional files and their content is needed:
events.xml file to “subscribe” to the event and say which observer should be fired ↵
2. An observer that adds a new layout handle to the page ↵
3. A layout file that adds needed changes to the page ↵
We are going to talk about event system approach in development. The event is a very flexible way to extend application logic. This approach is actual in both Magento 1 and Magento 2. Let’s go ahead and check how it works.
Hello guys, it’s time to tell you how to insert block into any place you want in Magento. As you know, very often we need to set some block into selected weird place without editing template, so we’ll try to describe the way how to do this using layouts and observers.
It is a good idea to create a new layout handle in Magento when we need to be able to easily customize styling of pages or enable/disable specific blocks for the customer groups. Here is how.