Skip to content

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.

HandlePageLayout File
orangecollar_blog_indexBlog post listingview/frontend/layout/orangecollar_blog_index.xml
orangecollar_post_viewSingle post pageview/frontend/layout/orangecollar_post_view.xml
orangecollar_category_viewCategory archiveview/frontend/layout/orangecollar_category_view.xml
orangecollar_tag_viewTag archiveview/frontend/layout/orangecollar_tag_view.xml
orangecollar_author_viewAuthor archiveview/frontend/layout/orangecollar_author_view.xml
orangecollar_search_resultsSearch resultsview/frontend/layout/orangecollar_search_results.xml

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.

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.