0

I'm running Magento 2.1.7 CE and I need to move the navigation.sections block inside of the header-wrapper. I found the reference to navigation.sections in vendor/magento/module-theme/view/frontend/layout/default.xml so I created a theme and I'm trying to modify the layout to just move that one block.

Here's the XML I setup to move navigation.sections inside of header-wrapper (saved under app/design/frontend/ThemeName/default/Magento_Theme/layout/default.xml):

<?xml version="1.0"?>
<page layout="3columns"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <move element="navigation.sections" destination="header-wrapper" before="logo" />
    </body>
</page>

This technically works and when I apply this theme the navigation.sections block is moved to that container, but only in developer mode. If I change to production mode with this theme enabled, I run into these issues:

  • magento setup:static-content:deploy fails (I need to clear a lot of directories under var/ to get it to work)
  • Cannot minify or bundle JS or CSS, it just fails
  • Layout on the front page is completely wrecked
  • Some CSS and JavaScript files 404. From what I've seen it's files like require.js that are included in the original layout.xml that I'm trying to extend

I tried copying the original layout.xml and just adding the move tag but no luck. The only way I can get it to work without Magento having a meltdown is by adding the move tag to the original file, but that's not what I want.

What am I doing wrong?

Here is my registration.php:

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/ThemeName/default',
    __DIR__
);

Here's my theme.xml:

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <!-- Theme's name -->
    <title>Theme Name</title> 
    <!-- Parent theme -->
    <parent>Magento/luma</parent> 
    <media>
        <!-- Theme's preview image -->
        <preview_image>media/preview.jpg</preview_image> 
    </media>
 </theme>

I found this in var/logs/exception.log:

"/path/to/magento/pub/static/frontend/ThemeName/default/en_US/mage/requirejs/mixins.js" 
Warning!file_get_contents(/path/to/magento/pub/static/frontend/ThemeName/default/en_US/mage/requirejs/mixins.js): 
failed to open stream: No such file or directory in /path/to/magento/vendor/magento/framework/Filesystem/Driver/File.php:149

So the compilation step is looking for requirejs/mixins.js which is NOT in my theme, I just want those pulled from the Luma theme. Again, what's an actual fix for this?

This is how I have been clearing cache so far:

rm -rf var/cache/* var/generation/* var/view_preprocessed/* var/page_cache/* pub/static/* var/di/* \
&& php bin/magento cache:flush
  • does your magento logs and php-error log give you more information? seems like the static-content is not generated correctly. Have you run the setup:di:compile command after changing to production mode? Do you use a specific locale? you can add the locale to static-content command setup:static-content:deploy xx_XX – juhanix Jun 2 '17 at 11:12
  • @juhanix I updated my question with my registration.php and theme.xml. My theme is literally these 3 files (plus media/preview.jpg). No locale, I have used setup:di:compile at least 10 times along with setup:static-content:deploy. I just checked the logs and I'll be updating my question with a CRITICAL error I found in there – charmeleon Jun 2 '17 at 14:19
  • Not to sound obtuse, but you shouldn't be extending the luma. You need to be falling back to blank or other. Luma is just a demo theme. – andy jones Jun 2 '17 at 14:35
  • @andyjones Thanks; I updated my theme.xml to extend Magento/blank but I'm seeing the exact same issue – charmeleon Jun 2 '17 at 14:59
  • @charmeleon great. Have you tried a reinstall? Clearing your vendo - composer update - composer install ? Removing preprocessed - cache - pub/static/frontend - pub/static/adminhtml ? Because i can't see your move affecting your build. It sounds like something is wrong in the whole build. Not theme related. – andy jones Jun 2 '17 at 15:11
0

This is a Magento bug: https://github.com/magento/magento2/issues/3754

Currently the workaround is to add a file under theme/web/images, e.g.: theme/web/images/dummy.jpg

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.