init
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\CmsLayout\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Framework\View\Page\Config as PageConfig;
|
||||
|
||||
class ApplyCustomFullWidthLayout implements ObserverInterface
|
||||
{
|
||||
private const PAGE_LAYOUT = 'cms-custom-full-width';
|
||||
|
||||
public function __construct(
|
||||
private readonly PageConfig $pageConfig
|
||||
) {
|
||||
}
|
||||
|
||||
public function execute(Observer $observer): void
|
||||
{
|
||||
if ($observer->getEvent()->getFullActionName() !== 'cms_page_view'
|
||||
|| $this->pageConfig->getPageLayout() !== self::PAGE_LAYOUT
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->pageConfig->addBodyClass('cms-custom-full-width');
|
||||
$this->pageConfig->addPageAsset('Magento_Theme::css/cms-custom-common.css');
|
||||
$observer->getEvent()->getLayout()->unsetElement('breadcrumbs');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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="layout_generate_blocks_after">
|
||||
<observer name="esun_cms_custom_full_width"
|
||||
instance="Esun\CmsLayout\Observer\ApplyCustomFullWidthLayout"/>
|
||||
</event>
|
||||
</config>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Esun_CmsLayout">
|
||||
<sequence>
|
||||
<module name="Magento_Cms"/>
|
||||
<module name="Magento_Theme"/>
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Esun_CmsLayout',
|
||||
__DIR__
|
||||
);
|
||||
Reference in New Issue
Block a user