2

I have in my CustomTheme a default.xml file. I tried to get the xml to work and used some of the samples I found here on StackExchange. Non of them are working for me? So apparently I have done something wrong or something else is interfering the xml file to be applied.

My default.xml resides in:

app/design/frontend///Magento_Theme/layout/default.xml

I cleared all cache, static files, the files in the /var and run setup:static-content:deploy

But nothing appears!

I tried several things like removing the footer links, and moving the shopping card like in this post:Magento 2 Block/Element order This is my latest trial default.xml the block is prepared in the cms_block. Using Magento 2.1.2

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="footer">
            <block class="Magento\Cms\Block\Block" name="footer_social_links_block">
            <arguments>
                <argument name="block_id" xsi:type="string" translate="true">dth_footer_social_links</argument>
            </arguments>
            </block>
        </referenceBlock>        
 </body>
</page>
2
  • After creating your custom theme, have you enabled it for your store in the admin panel? – Yaroslav Rogoza Nov 2 '16 at 16:35
  • yes the custom theme is working. I managed to include a Magento_Cms/layout/cms_index_index.xml which add some blocks to the cms homepage. But the default.xml does not work. – mr_typo3 Nov 2 '16 at 21:24
8

There's no issue in your layout file. Also, the layout file itself cannot be overridden by some extension. Only a separate parts (blocks, containers) can be overridden. Actually, there are many reasons why your changes are not being applied.

  • Your theme is not active at the moment. You have checked it. If changes in other layout files have effect, let's move forward.
  • The theme type is set as virtual. Known bug https://github.com/magento/magento2/issues/2996. But in that case not only default.xml but changes in all other layout files will have no effect.
  • The layout file is broken. It's not the case here
  • The path to the layout file is incorrect. It's always a good idea to double/triple check it.
  • The name of the layout file is incorrect. Believe or not, but cases like "defauit.xml" or similar can cost you few hours.
  • Your XML file has incorrect line endings and/or encoding. Sometimes it happens, you need to set UTF-8 encoding and Unix line endings for the layout file to be sure.

What would I recommend:

  • Make a parse error situation in the problematic file. Go to default.xml and remove some closing tag. Clear cache and reload a page. Then go to var/log/system.xml. If the file is handled by the system you will get "Theme layout update file .../default.xml is not valid" error there.
  • Make some change in the different default.xml file, for example app/design/frontend///Magento_Cms/layout/default.xml and check the situation once again.

Hope it will help.

10
  • Id tested the file with an error in it: – mr_typo3 Nov 3 '16 at 21:32
  • and it gave me the error. So the good news is, that its loaded. Now the question is why is it not used? I also have a default_head_blocks.xml in the same /layout dir could that interfere? – mr_typo3 Nov 3 '16 at 21:49
  • Even if you have some issues in the default_head_blocks.xml it should not affect the changes you make in default.xml. Have you tried something simple, like <referenceBlock name="footer" remove="true"/>? Try exactly this command inside of the <body> tag. Maybe this time it will work. – Yaroslav Rogoza Nov 4 '16 at 18:35
  • I tried this and its not working? Emptied all cache / static / generation etc and run setup:static-content:deploy <page xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="footer" remove="true"/> </body> </page> – mr_typo3 Nov 4 '16 at 19:13
  • In the log file i see things like this: main.INFO: Theme layout update file '/var/www/html/app/design/frontend/MenesTemplate/menes_theme/Magento_Theme/layout/default_head_blocks.xml' is not valid. Blank needed here Line: 1 [2016-11-04 19:15:31] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE2_49558e66b8a0ff76f5609cf962fba47b2 and handles default, catalog_product_view, catalog_product_view_id_42, catalog_product_view_sku_5090, catalog_product_view_type_simple, weltpixel_googlecards_remove_opengraph: Please correct the XML data and try again. Any idea what's wrong? – mr_typo3 Nov 5 '16 at 15:45
5

I had a similar issue to this (on CE 2.3.1, after setting up a staging server, with a fresh install of Magento, adding my custom theme and setting it under Content > Configuratio > Edit) and discovered that if I switched the Theme to Blank and back to my custom theme again it picked up all the correct layout configs.

---- Edit: Alternative solution

This issue came up again when setting up the store on another server. This time unsetting & setting the theme didn't seem to make any difference, however this post gave me the answer: https://github.com/magento/magento2/issues/12830#issuecomment-354610137

mysql> select * from theme \G;

If this is the issue you should see your theme_type is set to 1, rather than 0.

mysql> update theme set type = 0 where theme_path='vendor/theme';

(I actually added a parse error into my theme's Magento_Theme\layout\default.xml, as suggested above, to be sure I was hitting that file.)

Then clean cache and reload.

I'd be interested if anyone knows what the theme_type is for and when it is set?

1

I had the same problem today. I fixed it with switching to blank and back to my custom theme which is based on Luma theme. Changing the type didn't worked for me.

The type is defined in the ThemeInterface class. Basically there are three possible types: 0 = Physical Theme, 1 = Virtual Theme, 2 = Staging Theme

I have no idea whats the real difference. My custom theme has "1". Magentos default Themes have "0". So it looks like a custom theme, which is based on another physical theme is a virtual theme. Virtual themes also have the option to add custom js/css in their backend configuration (physical not). Staging theme looks like something from the enterprise version of magento. But the type is not really implemented right now. There are only a few references in code using it.

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.