Skip to content

Commit adc7b37

Browse files
committed
MC-2370: Implement full width layout for product
- Use result page plugin to apply default class
1 parent 35fca36 commit adc7b37

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Plugin\Result;
10+
11+
use Magento\Framework\App\ResponseInterface;
12+
use Magento\Framework\View\Element\Context;
13+
use Magento\Framework\View\Result\Page as ResultPage;
14+
15+
class Page
16+
{
17+
/**
18+
* @var \Magento\Framework\View\Element\Context
19+
*/
20+
private $context;
21+
22+
/**
23+
* @param Context $context
24+
*/
25+
public function __construct(
26+
Context $context
27+
) {
28+
$this->context = $context;
29+
}
30+
31+
/**
32+
* @param ResultPage $subject
33+
* @param ResponseInterface $response
34+
* @return array
35+
*/
36+
public function beforeRenderResult(
37+
ResultPage $subject,
38+
ResponseInterface $response
39+
) {
40+
// Apply the updated layout handles classes to the body when using our full width variants
41+
if ($subject->getConfig()->getPageLayout() == 'product-full-width') {
42+
$subject->getConfig()->addBodyClass('page-layout-1column');
43+
}
44+
45+
return [$response];
46+
}
47+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\Framework\View\Result\Page">
10+
<plugin name="pageLayoutDefaultClass" type="Magento\PageBuilder\Plugin\Result\Page"/>
11+
</type>
12+
</config>

app/code/Magento/PageBuilder/view/frontend/page_layout/product-full-width.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
99
<update handle="1column" />
1010

11-
<!-- Ensure the 1column page layout class is present in the DOM -->
12-
<referenceContainer name="page.wrapper" htmlClass="page-wrapper page-layout-1column"/>
13-
1411
<referenceContainer name="page.wrapper">
1512
<!-- Create new product details wrapper under main.content for tabs section -->
1613
<container name="product.info.details.wrapper" after="main.content" htmlTag="div" htmlClass="page-main page-main-details">

0 commit comments

Comments
 (0)