2

New to Magento 2 and not quite understanding the docs. In child Luma theme I am trying to move the currency switcher to the main header area (next to the minicart) but having no luck with it.

In /app/design/frontend/MyVendor/MyTheme/Magento_Theme/layout I placed the following default.xml:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<move element="currency" destination="header" after="minicart"/>
</page>

The switcher disappears from the panel header, but doesn't appear where I expect. I tried various combinations of before and after blocks and tried to move it to different blocks like maincontent, but in all cases I can't get it to show. There are a couple of previous posts from people trying to move the currency switcher but no successful answers so far. Is it possible? Moving it by phtml didn't work at all.

  • I think, You need to put move into <body> tag & put <?xml version="1.0"?> at the starting of xml – Pawan Mar 19 at 17:48
  • Did that, no change (see answer below). – webrightnow Mar 20 at 10:33
0

Correct xml should be :

<?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">
    <body>
        <move element="currency" destination="header" after="minicart"/>
    </body>
</page>
  • Sorry, <?xml version="1.0"?> was in there, I just hadn't pasted it into the question. Anyway, tried the above code and still nothing. I looked at the HTML output, there's not even any wrapping tags there. The block is just not being rendered at all. – webrightnow Mar 19 at 19:14
  • The site in question is at dev.lucemillpack.com. Looking at source code with the above xml in place, currency switcher is no longer in the panel header, but also nowhere else on the page. Changing destination to other blocks makes no difference. – webrightnow Mar 20 at 10:32
  • I have checked and currency switcher is available with dispaly:none. please search currency in your html. – Pawan Mar 20 at 17:20
  • I think that's part of the theme's responsive behaviour: some elements like the account links and currency switcher are actually included twice: once in the panel header and once in the navigation area. On screens above 767px width those elements are hidden from the navigation area with display: none. Below 767px, the panel header is hidden and the account links and currency switcher are shown as tabs in the navigation area. But there is no currency block in the main header area, which is where I would expect it to appear after using the above xml. – webrightnow Mar 21 at 19:58

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.