2

I want to move my custom tab from bottom to top in customer dashboard left sidebar.

I tried below thing

    <referenceBlock name="customer-account-navigation-account-link" remove="true"/>
    <referenceBlock name="customer_account_navigation">
                    <block class="Training\Msg\Block\Current" name="customer-account-navigation-account-customlink">
                        <arguments>
                            <argument name="label" xsi:type="string">Dashboard</argument>
                            <argument name="path" xsi:type="string">customer/account</argument>
                            <argument name="sortOrder" xsi:type="number">210</argument>
                        </arguments>
                    </block>
                </referenceBlock>
<move element="customer-account-navigation-account-customlink" destination="customer_account_navigation" before="customer-account-navigation-orders-link"/>

enter image description here

What I actually need is I want to change My Account tab name according to the customer group, all set well but the tab is display at the bottom.

  • Check my answer. – Rohan Hapani Oct 26 '18 at 10:15
  • please check answer i have posted. – Bhavin Gehlot Oct 26 '18 at 10:36
2

Hope you doing well.

I'm also facing this issue but after some time have solved this.

Follow mentioned steps.

create file at view/frontend/layout/customer_account.xml.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="customer_account_navigation">
                <block class="Magento\Customer\Block\Account\Delimiter" name="customer-account-navigation-delimiter-4" template="Vendor_Module::account/navigation-delimiter.phtml">
                    <arguments>
                        <argument name="sortOrder" xsi:type="number">1200</argument>
                    </arguments>
                    <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-custom-link">
                        <arguments>
                            <argument name="label" xsi:type="string" translate="true">Custom Link Title</argument>
                            <argument name="path" xsi:type="string">route/module/controller</argument>
                            <argument name="sortOrder" xsi:type="number">180</argument>
                        </arguments>
                    </block>
                </block>
        </referenceBlock>
    </body>
</page>

Now create Phtml file for customer-account-navigation-delimiter-4 block.

view/frontend/templates/account/navigation-delimiter.phtml

<?php echo $block->getChildHtml(); ?>

Hope you have the result you want. :-)

  • Ok @Bhavin thank you for your answer :) let me try this one, will let you know what happened – Hitesh Oct 26 '18 at 10:42
  • Your answer is work for me after changes in block file like extends \Magento\Customer\Block\Account\Delimiter and removed .phtml file as no need it in my case I already defined all the things into block file from Magento\Framework\View\Element\Html\Link\Current file +1 – Hitesh Oct 26 '18 at 11:07
1

Try below code :

<referenceBlock name="customer_account_navigation">
    <block class="Training\Msg\Block\Current" name="customer-account-navigation-account-customlink" before="-">
        <arguments>
            <argument name="label" xsi:type="string">Dashboard</argument>
            <argument name="path" xsi:type="string">customer/account</argument>
            <argument name="sortOrder" xsi:type="number">210</argument>
        </arguments>
    </block>
</referenceBlock>
  • Thanks for your answer @Mukesh but it's not working I just tried, the tab position is as it is – Hitesh Oct 26 '18 at 9:48
  • @Hit's you should remove before"-" from <block class="Magento\Customer\Block\Account\Navigation" name="customer_account_navigation" before="-"> in customer_account.xml – Mukesh Prajapati Oct 26 '18 at 9:52
  • ok let me try this – Hitesh Oct 26 '18 at 9:53
  • @Hit's is this done ? – Mukesh Prajapati Oct 26 '18 at 10:04
  • No @Mukesh it's not working still position is as it is – Hitesh Oct 26 '18 at 10:08
1

Change

<argument name="sortOrder" xsi:type="number">210</argument>

to

<argument name="sortOrder" xsi:type="number">500</argument>

Greater the number in sortOrder higher will be the link in the customer sidebar account navigation.

  • Ok @Anshu let me check this also – Hitesh Oct 26 '18 at 10:02
  • it's not working still position is as it is – Hitesh Oct 26 '18 at 10:08
  • @Hit's Have you cleaned cache? – Anshu Mishra Oct 26 '18 at 11:05
  • @Hit's Implement class Magento\Customer\Block\Account\SortLinkInterface to have sortOrder working correctly – Anshu Mishra Oct 26 '18 at 11:08
  • Yes I did all the things but still it was not work for me – Hitesh Oct 26 '18 at 11:08
1

You need to use block class Magento\Customer\Block\Account\SortLinkInterface and change sortOrder value.

Use this below code :

<referenceBlock name="customer_account_navigation">
        <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-orders-link">
            <arguments>
                <argument name="path" xsi:type="string">customer/account</argument>
                <argument name="label" xsi:type="string" translate="true">Testing</argument>
                <argument name="sortOrder" xsi:type="number">500</argument>
            </arguments>
        </block>
    </referenceBlock>
  • But I need the label as per customer group condition that's why I used custom block where I set label into _tohtml method get the reference from Magento\Framework\View\Element\Html\Link\Current file – Hitesh Oct 26 '18 at 10:18

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.