0

I inserted a button in customer/account navigation with the following file in my own module:

MyCompany/CustomRouter/view/frontend/layout/customer_account.xml:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"
      label="Customer My Account (All Pages)" design_abstraction="custom">
    <body>
        <referenceBlock name="customer_account_navigation">
            <block class="Magento\Framework\View\Element\Html\Link\Current"
                   name="customer-account-navigation-pricelist-configure">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">Download Pricelist (PDF)</argument>
                    <argument name="path" xsi:type="string">configurepricelist</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

However, the button shows at the top of the list instead of the bottom. Is there any way I can make it show up at the bottom instead? (Or at least, below the core three links supplied by the customer module - among the other extensions.) I feel "Account Dashboard" really should be the top order.

1 Answer 1

0

I found the answer, you should use the after or before attribute, like this:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"
      label="Customer My Account (All Pages)" design_abstraction="custom">
    <body>
        <referenceBlock name="customer_account_navigation">
            <block class="Magento\Framework\View\Element\Html\Link\Current"
                   name="customer-account-navigation-pricelist-configure"
                   after="customer-account-navigation-account-edit-link">
                <arguments>
                    <argument name="label" xsi:type="string" 
                              translate="true">Download Pricelist (PDF)</argument>
                    <argument name="path" 
                              xsi:type="string">configurepricelist</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

Note that if you have multiple that need to be sorted, they will all insert themselves directly after the element - so if the same name is used, they'll end up after that element in reverse order.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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