I am accessing observer (controller_action_layout_render_before
) through this:
app/code/Vendor/Module/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_action_layout_render_before">
<observer name="layout_render_before" instance="Vendor\Module\Observer\LayoutRender" />
</event>
</config>
My observer file
app/code/Vendor/Module/Observer/LayoutRender.php
<?php
namespace Vendor\Module\Observer;
class LayoutRender implements \Magento\Framework\Event\ObserverInterface
{
protected $_resultPageFactory;
public function __construct(\Magento\Framework\View\Result\PageFactory $resultPageFactory) {
$this->_resultPageFactory = $resultPageFactory;
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
$resultPage = $this->_resultPageFactory->create();
if (//PHP Check here) {
$pageConfig = $resultPage->getConfig();
$pageConfig->setPageLayout('1column');
}
}
}
My question is, how can I check if this is accessing on search page?