Customising Prestashop Module Templates

Please don’t edit those originals!

I came across this little gem a while ago on the Prestashop forum, and thought I would draw attention to it in the hopes that it will help someone, somewhere.

I’m not one to complain, but my pet hate is folks who edit the original source files on their stores, when there’s no need to. It bugged me in Zen Cart when people happily modified the “classic” and “default” template files, then wondered why it was difficult to upgrade… and lo and behold folks started doing the same thing to the Prestashop default theme too. Aaaargh!! How hard is it to make a copy, rename it and edit that version instead?

Where my purist instincts failed however, way back in the bad old days, was when it came to the .tpl files that were stored in the module directories themselves — there seems like there’s no choice but to edit them if you want to customise the output for your store — or is there!

The answer is surprisingly simple, and will make you nod your head in grateful appreciation… all you need to do is create a modules/ directory in your custom theme directory (well you aren’t going to be working in the default theme directory now are you), copy the original .tpl from the module directory into it and edit away to your heart’s content.

As an example, you can take the template file from the blockadvertising module (blockadvertising.tpl) and make a copy under /themes/mycooltheme/modules/blockadvertising. Now modify the copy of the original that looked like:


{l s='Advertising' mod='blockadvertising'}

to


{l s='A fantastic site for Prestashop goodies' mod='blockadvertising'}

Pure joy! Although the observant will notice that unless you edit the {$image} variable and place a static path to your graphic in its place, then you’ll have to change the picture in the module directory…. well you can’t have it all I guess.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.