How i Can Move Side Bar to Right on My Account Page
-
08-03-2021 - |
문제
I want to Move Side-bar on My Account Page to Right On The Basis Of Admin Configuration Value
After Some Research i found that it can be done by setting Page layout="2coloums-right"
i saw Lots of Post doing this in
app/design/...
EDIT
here is My
Vendor\Module\view\frontend\layout\customer_account.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-right" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Customer My Account (All Pages)" design_abstraction="custom">
</page>
how i can do this in my Custom Module
해결책
You will have to override customer_account_index.xml
.
To Override this file in your extension, copy customer_account_index.xml
at app/code/VendorName/ModuleName/view/frontend/layout
and add below code :
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-right" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="customer_account"/>
<body>
<referenceBlock name="page.main.title">
<action method="setPageTitle">
<argument translate="true" name="title" xsi:type="string">My Account</argument>
</action>
</referenceBlock>
<referenceContainer name="content">
<block class="Magento\Customer\Block\Account\Dashboard\Info" name="customer_account_dashboard_info" as="info" template="Magento_Customer::account/dashboard/info.phtml" cacheable="false"/>
<block class="Magento\Customer\Block\Account\Dashboard\Address" name="customer_account_dashboard_address" as="address" template="Magento_Customer::account/dashboard/address.phtml" cacheable="false"/>
</referenceContainer>
</body>
</page>
EDIT :
You can create around plugin for that.
1) create di.xml file at app/code/VendorName/ModuleName/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Customer\Controller\Account\Index">
<plugin name="MyCucomtLoginAccountLoginPost" type="VendorName\ModuleName\Plugin\Customer\Index" sortOrder="10" disabled="false"/>
</type>
</config>
2) Now, create plugin VendorName\ModuleName\Plugin\Customer\Index.php
:
<?php
namespace VendorName\ModuleName\Plugin\Customer;
class Index
{
protected $resultPageFactory;
public function __construct(
\Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
$this->resultPageFactory = $resultPageFactory;
}
public function aroundExecute(\Magento\Customer\Controller\Account\Index $subject, \Closure $proceed)
{
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->setPageLayout('2columns-right');
return $resultPage;
}
}
다른 팁
To override the layout file in module simple
SpaceName/ModuleName/view/frontend/layoutname.xml
Example
SpaceName/ModuleName/view/frontend/cms_index_index.xml
Your Case
SpaceName\ModuleName\view\frontend\layout\customer_account_index.xml