cancel
Showing results for 
Search instead for 
Did you mean: 

Override .phtml template file in module

SOLVED

Override .phtml template file in module

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>

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Override .phtml template file in module

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.

View solution in original post

6 REPLIES 6

Re: Override .phtml template file in module

Hi @bajgproton0731 

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!

Re: Override .phtml template file in module

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"?

Re: Override .phtml template file in module

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.

Re: Override .phtml template file in module

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 !

 

https://magento.stackexchange.com/questions/215979/magento-2-how-to-override-extension-frontend-temp... 

 

Hope it helps !

 

if issue solved,Click Kudos & Accept as Solution

Re: Override .phtml template file in module

i already tried this 

 

\app\code\My\GeoIpRedirect\ Amasty_GeoipRedirect\view\frontend\templates\popup.phtml

 but it dosen't work. 

 

 

Re: Override .phtml template file in module

For anyone else who ends up here override-phtml-file-using-custom-module-in-magento-2 is deprecated. See this instead: template-override-m2