batman42ca Posted March 12, 2013 Share Posted March 12, 2013 I've been searching around and I'm getting bits and pieces of the puzzle. I'd like to add a new css file, so I can override the style of various elements and keep all the CSS in one place and keep this local to my own theme. I have a few questions. 1) To begin customizing the default theme, do I really need to copy literally the contents of the entire default theme into my own custom theme folder or should I only be copying the things I want to change? For the moment all I want to do is change some css but copying the default theme directory leaves me with a copy of the img, js, lang, mobile, modules, pdf directories, none of which I currently want to modify but now I have duplicates of all of them. 2) I already know that I can simply modify my copy of the header.tpl file in my custom theme directory and add a link to my own css file, but although it's simple enough, I suspect this is not quite the right way. Should I be overriding the FrontController.php file instead (from within an override directory)? 3) If I do an override of a file like the FrontController.php file, can I place it within my custom theme directory somewhere so that the customization is only active for my specific theme? Link to comment Share on other sites More sharing options...
vekia Posted March 12, 2013 Share Posted March 12, 2013 1) well, the best thing in my opinion is to copy all files from old theme, why? If you don't change all necesary styles etc., it is possible that an item will not display correctly (404 no-image, backgrund etc.). New theme = new files. You can't display files from other theme. Link to comment Share on other sites More sharing options...
batman42ca Posted March 12, 2013 Author Share Posted March 12, 2013 Thanks for the response. I guess I was hoping that the override mechanism was similar to Wordpress. If I want to customize a theme with Wordpress, I only need to copy the files that I want to customize. I don't need to copy the entire theme. I guess with Prestashop, I must copy an entire theme to modify any small piece of it? Also, any thoughts on questions 2 and 3? Link to comment Share on other sites More sharing options...
RaPhiuS Posted March 13, 2013 Share Posted March 13, 2013 Hello, >2) I already know that I can simply modify my copy of the header.tpl file in my custom theme directory and add a link to my own >css file, but although it's simple enough, I suspect this is not quite the right way. Should I be overriding the FrontController.php file >nstead (from within an override directory)? You can always add as part of the header.tpl, since it's a theme template file so why couldn't you change it? ;-) Actually there is a way to do this in code if you write your own module code. Register your module to the hook displayHeader and then you could do something like this from your module code: public function hookDisplayHeader($params) { // Adding your custom CSS $this->context->controller->addCSS(_MODULE_DIR_.$this->name.'/views/css/yourcustom.css', 'all'); return; } Not sure to understand your point of overriding FrontController. Prestashop 1.5+ comes with ModuleFrontController and ModuleAdminController and I would say it is never a good idea to override a core Prestashop component and you should have strong reasons to do so. I will never say it enough but stay away from core code unless you have a solid case where it is required. >3) If I do an override of a file like the FrontController.php file, can I place it within my custom theme directory somewhere so that >the customization is only active for my specific theme? You need to read the documentation, your question do not make any sense. Get your mind clear around the fundamentals of Model View Controller. Please check http://doc.prestashop.com/display/PS15/Fundamentals BR, RaPhiuS Link to comment Share on other sites More sharing options...
batman42ca Posted March 14, 2013 Author Share Posted March 14, 2013 Not sure to understand your point of overriding FrontController. Prestashop 1.5+ comes with ModuleFrontController and ModuleAdminController and I would say it is never a good idea to override a core Prestashop component and you should have strong reasons to do so. I will never say it enough but stay away from core code unless you have a solid case where it is required. I thought I had to. You're saying I should modify override ModuleFrontController? Fine with me but there is a FrontController (and ModuleFrontController) in the override/classes directory which suggests to me that it's there to be overriden or enhanced. No? You need to read the documentation, I'm working on it. There is much to learn. >3) If I do an override of a file like the FrontController.php file, can I place it within my custom theme directory somewhere so that >the customization is only active for my specific theme? your question do not make any sense. Suppose I have 2 themes and I want to perform an override but I only want that override to occur for one fo my 2 themes. I would either need to detect within the override file which theme is being used or I would need the overriden code to be kept within a theme directory. Do I ever place overriden code in a theme directory? Link to comment Share on other sites More sharing options...
Recommended Posts