Magento2 theme layout files suddenly stopped working - magento

I am brand new to Magento, and am using Magento 2. I have a custom theme that has been working just fine. Suddenly, the files in my custom theme's Magento_Theme/layout folder seem to not be loading. In my layout folder I have default_head_blocks.xml and default.xml. BOTH files suddenly stopped working.
Here is my default_head_blocks.xml:
<?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">
<head>
<css src="css/bootstrap.min.css" />​
<css src="css/styles-m.css" />
<css src="css/styles-l.css" media="screen and (min-width: 768px)"/>
<script src="js/bootstrap.min.js"/>
<script src="js/site.js"></script>
</head>
</page>
And my default.xml:
<?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>
<referenceContainer name="header.panel">
<block class="Magento\Framework\View\Element\Html\Links" name="header.links">
<arguments>
<argument name="css_class" xsi:type="string">header links</argument>
</arguments>
</block>
</referenceContainer>
<referenceContainer name="footer">
<block class="Magento\Theme\Block\Html\Footer" name="absolute_footer" template="html/absolute_footer.phtml" />
</referenceContainer>
<referenceBlock name="report.bugs" remove="true"/>
<referenceBlock name="store.settings.currency" remove="true"/>
<referenceBlock name="catalog.compare.sidebar" remove="true"/>
<referenceBlock name="advanced-search-link" remove="true"/>
<referenceBlock name="skip_to_content" remove="true"/>
<referenceBlock name="store_switcher" remove="true"/>
<referenceBlock name="navigation.sections" remove="true"/>
<referenceBlock name="top.search" remove="true"/>
<referenceBlock name="footer_links" remove="true"/>
<move element="copyright" destination="before.body.end"/>
<move element="logo" destination="navigation.sections"/>
<move element="form.subscribe" destination="footer"/>
<move element="catalog.topnav" destination="header.container"/>
<move element="top.links" destination="footer"/>
</body>
</page>
As I stated the files were working perfectly fine at one point.
The files in my Magento_Theme/templates/html folder load just fine. Seems to only be the files in my layout folder.
Any ideas why this would be happening or how to fix it?

From my experience, instances like this would require you to do the following.
Clean Cache:
php bin/magento cache:clean
Flush Cache:
php bin/magento cache:flush
(optional) if clearing cache doesn't seem to show any changes, you might need to do a static deploy.
Static Deploy: Note: this will take a bit of time depending on your system.
php ./bin/magento setup:static-content:deploy --theme <your theme example myTheme/Default>
After these processes you can try and reload the page again.

You have added <script> in a wrong way inside inside the file default_head_blocks.xml.
<?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">
<head>
<css src="css/bootstrap.min.css" />​
<css src="css/styles-m.css" />
<css src="css/styles-l.css" media="screen and (min-width: 768px)"/>
<script src="js/bootstrap.min.js"/>
<script src="js/site.js"/>
</head>
</page>
Static Deploy:
php bin/magento setup:static-content:deploy
Flush Cache:
php bin/magento cache:flush

Just go to website database, open theme table and chagne type = 0 for your current theme. That's it :)

There's an issue with default_head_blocks.xml if the theme type is set to virtual. Check the type field in the theme table. If it's set to 1, try setting it to 0. Then clear the cache and reload the page. See if that does the trick.
See also: https://github.com/magento/magento2/issues/4330

Related

Magento 2.4.5 cannot remove container

I cannot remove container "header.panel.wrapper" specifically in my custom theme in magento 2.4.5.
If I add the line <referenceBlock name="header.panel.wrapper" remove="true"/> in the file from luma theme: vendor/magento/theme-frontend-luma/Magento_Theme/layout/default.xml, it removes. But if I create this file in my custome theme: app/design/frontend/Singree/walkbeyond/Magento_Theme/layout/default.xml, with the same content as the luma-theme file, it just won't remove.
This is the code of file Magento_Theme/layout/default.xml from my custom theme:
<?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>
<referenceContainer name="header.panel">
<referenceBlock name="header.panel.wrapper" remove="true"/>
<block class="Magento\Framework\View\Element\Html\Links" name="header.links">
<arguments>
<argument name="css_class" xsi:type="string">header links</argument>
</arguments>
</block>
</referenceContainer>
<referenceContainer name="footer">
<block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" after="footer_links" template="Magento_Store::switch/stores.phtml"/>
</referenceContainer>
<referenceBlock name="report.bugs" remove="true"/>
<move element="copyright" destination="before.body.end"/>
</body>
</page>
if you search for header.panel.wrapper you see its not a block, but it is defined as a container. So try and use:
<referenceContainer name="header.panel.wrapper" remove="true"/>
That should work in your custom theme.

Magento 2 Porto Theme Move Category Description Below Products

I am using Magento 2 on the Porto Theme and I am trying to edit the following file to get the category description to display below the products and I just cant solve it.
http://www.paulo19.sg-host.com/folding-tables/wooden-trestle-tables-cat/
Can anyone help.
Thank you
<?xml version="1.0"?>
<!--
/**
* Copyright © 2018 Porto. All rights reserved.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="page.top">
<block class="Magento\Catalog\Block\Category\View" name="category_banner" template="category/banner.phtml" ifconfig="porto_settings/category/category_description" before="-"/>
</referenceContainer>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="category/desc_main_column.phtml" ifconfig="porto_settings/category/category_description" before="category.products"/>
</referenceContainer>
<move element="category.image" destination="content" before="category_desc_main_column"/>
<referenceContainer name="sidebar.main">
<block class="Smartwave\Porto\Block\Template" name="category_view_custom_block" after="-" template="Magento_Catalog::category/custom_block.phtml"/>
</referenceContainer>
</body>
</page>
Well after looking at this for some time, finally got it.
In directory (suggest to use child theme but here is core location)
/app/design/frontend/Smartwave/porto/Magento_Catalog/layout/catalog_category_view.xml
<?xml version="1.0"?>
</referenceContainer>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="category/desc_main_column.phtml" ifconfig="porto_settings/category/category_description" before="category.products"/>
<block class="Magento\Catalog\Block\Category\View" name="category_banner" template="category/banner.phtml" ifconfig="porto_settings/category/category_description" after="category.products"/>
</referenceContainer>
<move element="category.image" destination="content" before="category_desc_main_column"/>
<referenceContainer name="sidebar.main">
<block class="Smartwave\Porto\Block\Template" name="category_view_custom_block" after="-" template="Magento_Catalog::category/custom_block.phtml"/>
</referenceContainer>
</body>
Same theme but I had to do this.
/app/design/frontend/Smartwave/porto/Magento_Catalog/layout/catalog_category_view.xml
<move element="category.description" destination="content" after="category.products.list"/>

Changing from magento plugin does not make effect , but changing from magento\vendor shows effect

I am pretty new to Magento and using Magento 2.2.6 to develop a plugin. I need to edit the search bar. So I added a file to my plugin folder
Plugin \view \frontend \ templates \ form.mini.phtml
This does not making any changes in my website. But when I put that same file into Magento \vendor \magento \module-search \view \frontend \templates\ form.mini.phtml . Now I want not to any files from that vendor folder. What can I do now ? Thank you.
Block form.mini.phtml define in Vendor\magento\module-search\view\frontend\layout\default.xml
<!--Vendor\magento\module-search\view\frontend\layout\default.xml -->
<referenceContainer name="header-wrapper">
<block class="Magento\Framework\View\Element\Template" name="top.search" as="topSearch" template="Magento_Search::form.mini.phtml" />
</referenceContainer>
Overwrite using layout in your module app\code\VendorName\view\frontend\layout\default.xml
edit file form.mini.phtml and put it to app\code\VendorName\view\frontend\templates\form.mini.phtml
<!-- app\code\VendorName\view\frontend\layout\default.xml -->
<?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>
<referenceContainer name="header-wrapper">
<block class="Magento\Framework\View\Element\Template" name="top.search" as="topSearch" template="VendorName_ModuleName::form.mini.phtml" />
</referenceContainer>
</body>
</page>
You can also overwrite the file in the theme without the layout file
edit file form.mini.phtml and put it to app\design\frontend\Vendor\ThemeName\Magento_Search\templates\form.mini.phtml

I need to override admin login page in magento2

I need to access the magento2 admin login page using my custom module.How can i override login.phtml into my custom template file like custom-login.phtml file.
Kindly check the below coding and give me some solutions,
Check the layout file view/adminhtml/layout/adminhtml_auth_login.xml
<?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>
<referenceBlock name="admin.login">
<arguments>
<argument name="template" xsi:type="string">Namespace_Modulename::admin/login.phtml</argument>
</arguments>
</referenceBlock>
In my custom module added that xml file and placed the login.phtml in my custom module. The file path was view/adminhtml/templates/admin/login.phtml.
Thanks in Advance
Try following layout update to set template.
<?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>
<referenceBlock name="admin.login">
<action method="setTemplate">
<argument name="template" xsi:type="string">Namespace_Modulename::admin/login.phtml</argument>
</action>
</referenceBlock>
</body>
</page>

Overwriting Templates with custom Module in Magento 2

I am trying to overwrite a template defined in /vendor/magento/module-grouped-product/view/frontend/layout/catalog_product_view_type_grouped.xml in a custom module. The file has a block named product.info.grouped defined like so:
<block class="Magento\GroupedProduct\Block\Product\View\Type\Grouped" name="product.info.grouped" before="product.info.addtocart" template="product/view/type/grouped.phtml"/>
So I created a file /app/code/FortyThree/GroupedConfigurableProduct/view/frontend/layout/catalog_product_view_type_grouped.xml and in it
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<referenceBlock name="product.info.grouped">
<action method="setTemplate">
<argument name="template" xsi:type="string">FortyThree_GroupedConfigurableProduct::product/view/type/grouped.phtml</argument>
</action>
</referenceBlock>
</layout>
and created the corresponding .phtml file but it doesn't overwrite the original template file. Is there something else I need to do to get the overwrite to register? I've tried setup:upgrade and flushing the cached nothing seems to work. I also have the Magento_GroupedProduct set in the sequence section of my module.xml to make sure its loading after.
It really doesn't seem like my catalog_product_view_type_grouped.xml is being read at all since nothing I do in there seems to do matter.
You layout file isn't good.
This should do the trick :
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.grouped">
<action method="setTemplate">
<argument name="template" xsi:type="string">FortyThree_GroupedConfigurableProduct::product/view/type/grouped.phtml</argument>
</action>
</referenceBlock>
</body>
</page>
Also don't forget to add a dependency to GroupedProduct in your module.
There are a few ways to check if you are referencing properly a block. You could simply use a remove, to see if that works to confirm that you have the proper block.

Resources