2

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.

enter image description here

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" />

  • Can you please update your XML file's code where you have this profile pic block ? – Kishan Savaliya Nov 18 '19 at 11:28
  • <referenceContainer name="sidebar.main"> <block class="Vendor\Module\Block\Testing" name="customer.session.data" template="Vendor_Module::Test.phtml" cacheable="false" /> </referenceContainer> – Siva Nov 18 '19 at 11:30
  • Above is my XML code – Siva Nov 18 '19 at 11:30
3

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!

| improve this answer | |
  • Let me know if it helps. – Kishan Savaliya Nov 18 '19 at 11:36
  • 1
    Thanks @Kishan, it works great – Siva Nov 18 '19 at 11:40
  • 1
    You're welcome @Siva – Kishan Savaliya Nov 18 '19 at 12:02
0

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" /> 
| improve this answer | |
  • Thanks for your time. I have tried but its not working. Checked with @Kishan answer and it works fine. – Siva Nov 18 '19 at 11:39

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.