Magento2.3: How to move the custom block in account navigation sidebar?
-
20-03-2021 - |
Question
I want to show the customer profile pic and the name after he/she logged in on the account navigation sidebar. I have successfully got those details. Please see below.
However, I want to show them above the My Account link. I have tried moving but not success.
Can anyone please guide me on this?
<referenceContainer name="sidebar.main">
<block class="Vendor\Module\Block\Testing" name="customer.session.data" template="Vendor_Module::Test.phtml" before="customer-account-navigation-account-edit-link" cacheable="false" />
Solution
Update your XML with below content and check
<block class="Vendor\Module\Block\Testing" name="customer.session.data" template="Vendor_Module::Test.phtml" before="-" cacheable="false" />
Or
Add this line after referenceContainer tag
<move element="customer.session.data" destination="sidebar.main" before="-" />
Or
<referenceContainer name="sidebar.main.account_nav">
<block class="Vendor\Module\Block\Testing" name="customer.session.data" template="Vendor_Module::Test.phtml" before="-" cacheable="false" />
</referenceContainer>
Hope this will help you!
OTHER TIPS
Try adding your block before sidebar.main.account_nav
block, i.e your code in xml file-
<block class="Vendor\Module\Block\Testing" name="customer.session.data" template="Vendor_Module::Test.phtml" cacheable="false" before="sidebar.main.account_nav" />
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange