hello,
i have question if there is possibility to override .phtml from 3rd party module (not theme) in my module (not theme) only by (i know that there are other methods) placing new .phtml files in specified directory?
FIle that i want to overrider:
\vendor\amasty\geoipredirect\view\frontend\templates\popup.phtml
I tried locations:
\app\code\My\GeoipRedirect\Amasty_GeoipRedirect\view\frontend\templates\popup.phtml \app\code\My\GeoIpRedirect\view\frontend\templates\Amasty_GeoipRedirect\popup.phtml
and the same question is about overriding layout .xml files, can i do it only by placing files with the same name?
i made im module.xml i have
<sequence> <module name="Amasty_GeoipRedirect"/> </sequence>
Solved! Go to Solution.
HI @bajgproton0731
Yes, you need to do the additional steps as well if you want to override in custom module.
If you want to override in theme then you can do in single step.
Yes, You can override .phtml file of any extension in your custom module.
Follow the below link:
override-phtml-file-using-custom-module-in-magento-2/
I hope it will help you!
in override-phtml-file-using-custom-module-in-magento-2/
are two methods for overriding, but both of them involves additional steps to override .phtml (not only creating .phtml files and placing them into specified directory), so there is no way?
In override-phtml-file-using-custom-module-in-magento-2/ there is method for overriding .phtml.
Is also method for overriding layout .xml files form 3rd pardy module in our module?
I know that we can use comands like "referencingBlock".... , but i mean there is way to just replace 3party .xml layout file in module - not just modyfied it by using comands like "referencinBlock"?
HI @bajgproton0731
Yes, you need to do the additional steps as well if you want to override in custom module.
If you want to override in theme then you can do in single step.
Hello @bajgproton0731
Yes you can override the third-party extension phtml file (templates) and layout files the same as the way we override core Magento's templates and layouts.
So in your case following is the correct way to override the template and layout files.
\app\code\My\GeoIpRedirect\ Amasty_GeoipRedirect\view\frontend\templates\popup.phtml
For the layout files also you will need to follow the same structure.
For more details refer the following links for the same !
Hope it helps !
i already tried this
\app\code\My\GeoIpRedirect\ Amasty_GeoipRedirect\view\frontend\templates\popup.phtml
but it dosen't work.
For anyone else who ends up here override-phtml-file-using-custom-module-in-magento-2 is deprecated. See this instead: template-override-m2