0

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

  • I don't know why someone give -1 on this, but this question is not that bad. +1 on you question @waqar – Shoaib Munir Jul 30 at 8:08
  • yup @ShoaibMunir i was aslo confused : ( – Waqar Ali Jul 30 at 8:09
2

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;

    }
}
  • how i can change this Programmatically i actually want to this on the basis of admin congifutration value – Waqar Ali Jul 30 at 9:41
  • Not sure by configuration. But, You can change by controller. – Mona Mehta Jul 30 at 9:43
  • how i can change it by controller please let me know – Waqar Ali Jul 30 at 9:44
  • Please check my updated answer. – Mona Mehta Jul 30 at 9:56
2

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
  • I have tried this but its not working for me – Waqar Ali Jul 30 at 9:14
  • Share your code. – Qaisar Satti Jul 30 at 9:15
  • @Qaiser bhai check my updated Question – Waqar Ali Jul 30 at 9:17
  • use this layout file Vendor\Module\view\frontend\layout\customer_account_index.xml – Qaisar Satti Jul 30 at 9:26
  • okay let me try – Waqar Ali Jul 30 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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