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

3
  • Can you please update your XML file's code where you have this profile pic block ? Commented Nov 18, 2019 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>
    – MagentoDev
    Commented Nov 18, 2019 at 11:30
  • Above is my XML code
    – MagentoDev
    Commented Nov 18, 2019 at 11:30

2 Answers 2

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!

3
  • Let me know if it helps. Commented Nov 18, 2019 at 11:36
  • 1
    Thanks @Kishan, it works great
    – MagentoDev
    Commented Nov 18, 2019 at 11:40
  • 1
    You're welcome @Siva Commented Nov 18, 2019 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" /> 
1
  • Thanks for your time. I have tried but its not working. Checked with @Kishan answer and it works fine.
    – MagentoDev
    Commented Nov 18, 2019 at 11:39

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.