2

I try to assign a CSS class to navigation ( tag) under customer account page.

I found this file customer_account.xml, and I added <argument name="css_class" xsi:type="string">sidebar-navigation__item-link</argument> to the block, as following

                    <block class="Magento\Customer\Block\Account\SortLinkInterface"
                           name="customer-account-navigation-address-link">
                        <arguments>
                            <argument name="css_class" xsi:type="string">sidebar-navigation__item-link</argument>
                            <argument name="label" xsi:type="string" translate="true">Address Book</argument>
                            <argument name="path" xsi:type="string">customer/addresss</argument>
                            <argument name="sortOrder" xsi:type="number">190</argument>
                        </arguments>
                    </block>

But this doesn't give any effect on the frontpage. I have cleared the cache.

Did I miss anything?

1 Answer 1

5

Try following way:

<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-orders-link-2">
    <arguments>
        <argument name="path" xsi:type="string">sales/order/history</argument>
        <argument name="label" xsi:type="string" translate="true">My Orders 2</argument>
        <argument name="sortOrder" xsi:type="number">230</argument>
        <argument name="attributes" xsi:type="array">
            <item name="class" xsi:type="string">my_custom_link</item>
        </argument>
    </arguments>
</block>
4
  • It's working. Thanks. how come I didn't know this. Commented Mar 7, 2019 at 9:10
  • I want to add class to li and not a. Because once the 'current' class is added to li, the child is changed to 'strong' instead of anchor. Please help. Commented Sep 11, 2019 at 8:16
  • when I try to add class it adds class but removes add other tabs on account navigation @Sohel Rana Commented Apr 20, 2021 at 18:58
  • @SejalShah have you found any solution for your requirement? Commented Apr 26, 2021 at 6:31

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.