1

How a HTML view of Magento 2 composed ? I know this is a broad question.

Actually I am trying to remove Header and Footer from Print out of Sales Order. I can see a HTML view of Magento 2 when I am browsing this URL https://chaldal.com/sales/order/print/order_id/13/.I need to remove some portion of this HTML view. In this regard I turned on Enabled Template Path Hints for Storefront. I found that there is no main .phtml file which has to contain all the .phtml file.So that I can remove some of the .phtml files and keep some of them to have my desired HTML view.

I have to remove these .phtml files /home/theuaeex/public_html/app/design/frontend/Alothemes/default/Magento_Theme/templates/html/header.phtml

/home/theuaeex/public_html/app/design/frontend/Alothemes/default/Magiccart_Magicproduct/templates/productcustom.phtml and /home/theuaeex/public_html/app/design/frontend/Alothemes/default/Magento_Theme/templates/html/footer.phtml.

I tried through .xml files to remove those inclusion but failed.

Here is my print.xml file.

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <attribute name="class" value="page-print"/>
        <referenceContainer name="header.container" remove="true"/>
        <referenceBlock name="catalog.topnav" remove="true"/>
        <referenceContainer name="footer-container" remove="true"/>
        <move element="logo" destination="main.content" before="-" />
        <move element="copyright" destination="main.content" after="-" />
        <referenceContainer name="before.body.end">
            <block class="Magento\Framework\View\Element\Template" name="sales.order.print.js" template="Magento_Theme::html/print.phtml" />
        </referenceContainer>
    </body>
</page> 
1

Copy layout from

vendor/magento/module-theme/view/frontend/layout/print.xml

to

/home/theuaeex/public_html/app/design/frontend/Alothemes/default/Magento_Theme/layout/print.xml

and use the layout handle

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="print" />
    <body>
    </body>
</page>

Or you can remove the header footer

<?xml version="1.0"?>

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header.container" remove="true"/>
        <referenceBlock name="catalog.topnav" remove="true"/>
        <referenceContainer name="footer-container" remove="true"/>
    </body>
</page>
  • Thanks @Qaisar Satti for your reply. I tried your solution but it is not working. Thanks – abu abu Nov 16 '17 at 7:46
  • @abuabu share your update layout code so i can look at that – Qaisar Satti Nov 16 '17 at 7:48
  • I updated my question with my print.xml file code which is copied to /home/theuaeex/public_html/app/design/frontend/Alothemes/default/Magento_Theme/layout. Thanks – abu abu Nov 16 '17 at 7:52
  • 1
    @abuabu no other clue . – Qaisar Satti Nov 16 '17 at 11:20
  • 1
    this example is responsible for removing header and footer vendor/magento/module-theme/view/frontend/layout/print.xml – Qaisar Satti Nov 20 '17 at 5:15

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.