Layout Handles
The Observer/LayoutLoadBefore.php observer dynamically adds a layout handle to every blog page request. These handles allow targeted layout customization per page type.
Layout Handles
Section titled “Layout Handles”| Handle | Page | Layout File |
|---|---|---|
orangecollar_blog_index | Blog post listing | view/frontend/layout/orangecollar_blog_index.xml |
orangecollar_post_view | Single post page | view/frontend/layout/orangecollar_post_view.xml |
orangecollar_category_view | Category archive | view/frontend/layout/orangecollar_category_view.xml |
orangecollar_tag_view | Tag archive | view/frontend/layout/orangecollar_tag_view.xml |
orangecollar_author_view | Author archive | view/frontend/layout/orangecollar_author_view.xml |
orangecollar_search_results | Search results | view/frontend/layout/orangecollar_search_results.xml |
How Handles Are Added
Section titled “How Handles Are Added”The handle name is constructed as orangecollar_{controller}_{action}:
- Controller name: the request controller name (set by the Router based on the URL pattern matched)
- Action: the controller action name (
index,view,results)
For the post view controller, the handle is orangecollar_post_view. For the blog index controller, it is orangecollar_blog_index.
Using Layout Handles in Your Theme
Section titled “Using Layout Handles in Your Theme”To add content to the blog listing page sidebar in your theme:
File: app/design/frontend/Your/Theme/OrangeCollar_WordPressIntegration/layout/orangecollar_blog_index.xml
<?xml version="1.0"?><page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="sidebar.main"> <block class="OrangeCollar\WordPressIntegration\Block\Sidebar\Categories" name="blog.sidebar.categories" template="OrangeCollar_WordPressIntegration::sidebar/categories.phtml" after="-"/> </referenceContainer> </body></page>To apply changes to all blog page types at once, use a layout update that references all six handles.