I have put 2 remove tags inside default_head_blocks.xml:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<remove src="css/print.css"/>
<remove src="css/styles-m.css"/>
</head>
</page>
The file is under app/design/frontend/<theme>/Magento_Theme/layout/
But the css files are not being removed. Should I put the file in a different directory?
Directory is correct. can you please try to flush cache and check again.
Related
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 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
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>
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.
I use the external resources mapping by glassfish for storing user uploaded images (sun-web.xml):
<property name="downloadroot" value="from=/downloaded dir=c:\glassfishv3\downloads"/>
I store uploaded images to this directory. The first download is ok, the image is shown at the address server:8080/downloaded/image_13.png. But when the users uploads another file and replaces the image (it is really replaced in file system) the GF doesn't show new image, but the old one. Event restart and osgi-cache/generated clean doesn't help! That's very misleading and hope anyone could help me with this issue..
Ok, the issue was in JRebel! I spent the whole day, and finally found the issue! So, if anyone meets with it, the reciept to fix is to include the gf virtual path to rebel.xml like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<application>
<classpath>
<dir name="${myproject.root}\target\classes" />
</classpath>
<web>
<link target="">
<dir name="${myproject.root}\src\main\webapp" />
</link>
<link target="">
<dir name="C:\glassfish3.1" />
</link>
</web>
</application>