1

pls help me move minicart to after catalog.nav,im rewrite topmenu.phtml and call

$this->getLayout()->createBlock('Magento\Checkout\Block\Cart\Sidebar')->setTemplate('Magento_Checkout::cart/minicart.phtml')->toHtml()

minicart show correct but when click popup minicart show content blank
2

1 Answer 1

7

Why you don't try to move it with xml update. Add this to default.xml layout in your theme:

<move element="minicart" destination="navigation.sections" />

The navigation.sections block is defined in vendor/magento/theme-frontend-blank/Magento_Theme/layout/default.xml.

Then you need to override sections.phtml in your theme app/design/frontend/Vendor/Theme/Magento_Theme/templates/html/sections.phtml and display minicart block by adding this at the end of the file.

<?php echo $this->getChildHtml('minicart') ?>
1
  • 1
    If I want to add in it header.phtml file. I've tried this code: <move element="minicart" destination="header.container" /> in default.xml and <?php echo $this->getChildHtml('minicart'); ?> in header.phtml but it does not work
    – anujeet
    Commented Mar 1, 2017 at 7:00

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.