Jump to content

override tpl file

Nishith Nesdiya

Recommended Posts

can you say something more what you want to achievie? it will be much easier to suggest what you have to do


btw. It isn't possible because someone can use different theme (non-default) so when you will override this file you will crash the theme

Link to comment
Share on other sites

so you want to remove default "cover" (image) ?

i think that you can do a little trick with jquery :)


in productFooter create div with your video

for example: <div id="myproductvideo">VIDEO HERE</div>


add there also script with jquery function to move myproductvideo div to the image cover DOM element.

you can do it easily with jquery with script like




where DOM_ELEMENT is a place where you want to display video



no overrides - no worries ;)

  • Like 3
Link to comment
Share on other sites

  • 8 months later...

First of all thank you.


OK that's what I thought.

The real question is :


When I download a theme and it gets updated, how can I benefit from new features without comparing each line of code ?


For CSS it's easy I import my file last.


But for the rest...

Link to comment
Share on other sites

  • 1 year later...

Old thread but someone might find this useful while Googling.


Actually, it is possible to "override" the theme product.tpl file from your module.


Your module needs to override the ProductController.php file. You need to look for the setTemplate() call in the init() function, and you can change the path of the template, which would reside somewhere in your module. If you upgrade Prestashop core, you have another overriden function you need to check and possibly revise, and you also need to make sure no other module is overriding the same function.


Another method is to write some code that physically copies and pastes the .tpl file to the template when the module is installed, and then reverse what you did when the module is uninstalled (which means your code would need to have taken a backup of the original file).


Either method is very simple and will work. Of course, I have made no assumptions of the big picture you are trying to achieve. These methods are fine for privately used modules. As long as you can keep track of your changes, you should be fine. However, if you are distributing these modules to the public, overriding the tpl file would likely break the theme as has been pointed out, because you do not know what theme they are using.


Perhaps an advantage of not editing the theme directly means you can encapsulate your edits neatly inside modules only so you can turn the edits on and off via the control panel, or perhaps you have conditional code that will load a different template. A more philosophical argument is that by keeping all edits in modules only, it is always clear where your changes are so easier to manage, but I'm not convinced by that argument because VCS  can easily tell you what files have been changed. If the choice was mine, I would edit the theme directly.

Edited by helloworlder (see edit history)
  • Like 2
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...