I have checked the best solution. But not able to override the footer for my custom module.
Does anyone have a solution for this?
Thanks
I have checked the best solution. But not able to override the footer for my custom module.
Does anyone have a solution for this?
Thanks
You need to create default.xml
file in your custom module here
app/code/Vendor/Module/view/frontend/layout/default.xml
Content for this file is..
<?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="footer">
<block class="Magento\Framework\View\Element\Template" name="custom_jquery" after="-" template="Vendor_Module::custom_jquery.phtml"/>
</referenceContainer>
</body>
</page>
Now you need to create one template file here on this path in your custom module.
app/code/Vendor/Module/view/frontend/templates/custom_jquery.phtml
Content for this file is..
<script type="text/javascript">
(function () {
require(["jquery"], function($) {
$(document).ready(function($) {
/*You can add your custom jQuery code here*/
alert("Hello");
});
});
})();
</script>
Hope this will help you!
Instead of override footer you can add your custom block into footer-container `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="footer-container">
<block class="Magento\Framework\View\Element\Template" name="custom_block-jquery" template="Vendor_ModuleName::html/customBlock.phtml"/>
</referenceContainer>
</body>
</page>
And add jquery content inside your phtml template or you can directly load jquery into default.xml
file on header.
Anything you will place into default.xml
will load on all pages.