The standard layout of my categories is 2-columns-left so that the layered navigation is visible in my shop. What I want is, to use the same categories to display content.

This is an example for my shop link: products/chemicals.html If I click this link my products are shown in my list.phtml

This is an example for my "cms" link: products/chemicals.html?cms_id=123 If I click this link my "cms" content is displayed in my list.phtml

What I want now, is to display my content without the left sidebar. By CSS I can set the sidebar display:none, that works, but the page loads my products.

I would prefer to change the page layout when I call my "cms" category page.

Any idea?



1 Answer 1


Create a frontend/events.xml

<event name="layout_load_before">
    <observer name="test_layout_change" instance="Tets\Module\Observer\AddUpdateHandlesObserver" />

Create class for Observer.

namespace Test\Module\Observer;

use Magento\Framework\Event\ObserverInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Event\Observer;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Request\Http;

 * Class AddUpdateHandlesObserver
 * @package Test\Module\Observer
class AddUpdateHandlesObserver implements ObserverInterface

 * @var Http
protected $request;

 * @var StoreManagerInterface
protected $storeManager;

 * @var ProductRepositoryInterface
protected $productRepository;

 * AddUpdateHandlesObserver constructor.
 * @param Http                       $request           Request
 * @param StoreManagerInterface      $storeManager      StoreManager
 * @param ProductRepositoryInterface $productRepository ProductRepository
public function __construct(
    Http $request,
    StoreManagerInterface $storeManager,
    ProductRepositoryInterface $productRepository
) {
    $this->request           = $request;
    $this->storeManager      = $storeManager;
    $this->productRepository = $productRepository;
}//end __construct()

 * @param Observer $observer Observer
 * @return $this|bool|void
public function execute(Observer $observer)
    $layout         = $observer->getData('layout');

    if ({ur_conditon}) {


    return $this;
}//end execute()

}//end class

Create layout_file_name.xml Inside extend the parent_layout file and remove the respective sidebar from the xml file.

<update handle="catalog_category_view" />
<referenceBlock name="block_name_which_you_want_remove" remove="true" />
  • Thank you for your help. I have not been here since a long time. Jan 26, 2020 at 13:21

Your Answer

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

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