0

trying to add a phtml through xml to account page sidebar. but i am not getting it right. the xml code is: enter image description here

  • Please update your XML content in question – Kishan Savaliya Oct 22 at 5:23
  • I was unable to upload xml. so I uploaded a picture. – Chandan Sayed Oct 22 at 5:40
  • You can not upload file but you can copy content of file and then you can paste here – Kishan Savaliya Oct 22 at 5:42
  • <?xml version="1.0"?> <page xmlns:xsi="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> <referenceContainer name="sidebar.main"> <block class="Magento\Framework\View\Element\Template" name="test" template="Magento_Theme::html/test.phtml" before="-"/> </referenceBlock> </body> </page> – Chandan Sayed Oct 22 at 5:43
  • 1
    the issue is your starting tag is <referenceContainer> but your ending tag in <referenceBlock>... kindly change <referenceBlock> to <referenceContainer> – Asad Khan Oct 22 at 5:46
1

You can add your customer_account.xml file here in this path

app/design/frontend/Vendor/Theme/Magento_Customer/layout/customer_account.xml

Content for this file is ..

<?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>
        <referenceContainer name="sidebar.main">
            <block class="Magento\Framework\View\Element\Template" name="sidebar.main.new.template" template="Magento_Customer::customer/sidebar.phtml" />
        </referenceContainer>
    </body>
</page>

And you can create your template file here..

app/design/frontend/Vendor/Theme/Magento_Customer/templates/customer/sidebar.phtml

Content for this file is ..

<?php echo "Test content"; ?>

After adding both files please run below commands in CLI

php bin/magento cache:clean
php bin/magento cache:flush

Hope this will help you!

  • Did you tried this ? – Kishan Savaliya Oct 22 at 6:07
  • thank you. but it is not working. – Chandan Sayed Oct 22 at 6:36
  • Where you are trying to add xml file ? – Kishan Savaliya Oct 22 at 6:36
  • Can you please send me path of your xml and template file ? – Kishan Savaliya Oct 22 at 6:36
  • Magento_Theme/templates/html/test.phtml – Chandan Sayed Oct 22 at 6: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.