I'm new in prestashop. I created my css file and want to add it to prestashop theme. How can i add the new fill and make prestashop read the file in the header section? In forums i see that they said to add it to hookheader , i tried to add it to some module and do the following:
1) add to the theme header file {hook h="myCssHook"}
2) add to some rendom module function:
public function myCsshook(¶ms)
{
$this->context->controller->addCSS(($this->_path).'prestashop/myshop/theme/css/myoverride/myCsstheme.css', 'all');
}
3) in the module installition copy and add:
|| $this->registerHook('myCssHook') == false
and it didn't work. I'm using prestashop 1.6.1.1
The best way to do that is to add the following in the setMedia() function of the correct controller file.
For example, if you want to add your css to all your Products pages, you will have to add this code in controllers/front/ProductController.php after
If you want to add it to all your pages, you will have to add this code in classes/controller/FrontController.php after
An even better (and cleaner) way to do that is to create an override file.
For example, for FrontController, create a new file named FrontController.php in override/classes/controller/FrontController.php and put this code:
You can create an override file for each of your controllers. As you wish.
@ébewè: That is definately not the best way to do it because with the next software update that will most probably be overwritten again.
if you want to do this in the controller itself, then create an override of that class in overrides/controllers/yourcontrollers and do it in that override. That way your work won't be overwritten with a software opdate.
If you work on a module, then you create the css file inside the module (f.i. css/mycss.css) and in the appropriate hook you add:
and if you want that also in your theme then you add the file also in
but if you don't need to alter the css in your theme, then that is not necessary.