0
votes

I want to add CSS for my custom module.

mymodule.php

public function hookDisplayHeader()
{
          $this->context->controller->addCSS($this->_path . 'views/css/mymodule.css', 'all');//path of css
}

This code dont' work !

Thanks for your help

1

1 Answers

2
votes

This function could work, but is deprecated since PrestaShop 1.7.
You must use registerStylesheet instead, like that:

$this->context->controller->registerStylesheet(
    'modules-mymodule', //This id has to be unique
    'modules/'.$this->name.'/views/css/mymodule.css',
    array('media' => 'all', 'priority' => 150)
);

You can find more information about this function here: https://devdocs.prestashop.com/1.7/themes/getting-started/asset-management/