4

Actually, I am trying to add signOut link in My Dashboard end of the page where other links are listed programmatically using magento 2.

can any one idea related it.

1
12

Add Magento_Customer/layout/customer_account.xml file in your theme folder and paste content below :

    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>        

        <referenceBlock name="customer_account_navigation"><!--ifconfig="wishlist/general/active"-->
            <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-logout-link">
                <arguments>
                    <argument name="path" xsi:type="string">customer/account/logout</argument>
                    <argument name="label" xsi:type="string">Logout</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>
0

Create a customer_account.xml file under your theme directory /app/design/frontend///Magento_Customer/layout/ and add the following code.

<?xml version="1.0"?> 
<page layout="2columns-left" xmlns xsi="http://wwww3.org/2001/XMLSchema-instance" 
  xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/ete/page_configuration.xsd"> 
<body>
      <referenceBlock name="customer_account_navigation"> 
          <block class="Magento\Framework\View\Element\Html\Link\Current" Name="customer-account-navagation-signout-link">
          <arguments>
               <argument name="path" xsi:type="string">customer/account/logout</argument>
               <argument name="label" xsi:type="string">Sign Out</argument>
          </arguments>
          </block>
     </referenceBlock>
 </body>
</page> 

Clean Magento Cache, Sign In, and navigate to the My Account. At the bottom of the Navigation menu, you have to see the Sign Out link as in the screen below.

enter image description here

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.