Jump to content

How to add JS and CSS in back-office?


Recommended Posts

Hi everybody,


I need to know how to add a Javascript and Css in my tab in back-office... I saw the list of all hooks and tried with - "





public function backOfficeHeader($params) {
    Tools::addCSS((__PS_BASE_URI__).'modules/'.$this->name.'/css/'.$this->name.'.css', 'all');


But when I visit my tab everything still the same and the javascript and css are not added in the header, so where is the problem?!

Link to comment
Share on other sites

  • 5 weeks later...
  • 3 weeks later...

The "Tools:AddJS" is not working in backoffice i don't know why


I use this instead. This doesnt put them in head but works for me


 public function hookbackOfficeTop($params){
	echo '<script type="text/javascript" src="'.(__PS_BASE_URI__).'modules/'.$this->name.'/js/goodold.js" />';


Edited by borantula (see edit history)
Link to comment
Share on other sites

  • 1 year later...
  • 11 months later...
  • 1 month later...

i know this is very old topic, but i suggest to do


$this->context->controller->addCSS(Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/css/your_custom_css.css');
This code can be added on method called _displayModuleName()
Example, if your module name is "Sample", edit the file "modules/sample/sample.php" like this:
private function _displaySample()
    $this->context->controller->addCSS(Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/css/your_custom_css.css');
    return $this->display(__FILE__, 'infos.tpl');

The css file will be added properly to HTML <head>.

Edited by omine (see edit history)
  • Thanks 1
Link to comment
Share on other sites

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...