t0m3kk Posted March 31, 2012 Share Posted March 31, 2012 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 - " backOfficeHeader" : Example: public function backOfficeHeader($params) { Tools::addJS((__PS_BASE_URI__).'modules/'.$this->name.'/js/'.$this->name.'.js'); 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 More sharing options...
t0m3kk Posted April 30, 2012 Author Share Posted April 30, 2012 Anybody!? Link to comment Share on other sites More sharing options...
t0m3kk Posted May 20, 2012 Author Share Posted May 20, 2012 up Link to comment Share on other sites More sharing options...
borantula Posted May 22, 2012 Share Posted May 22, 2012 (edited) 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 May 22, 2012 by borantula (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted February 10, 2014 Share Posted February 10, 2014 backOfficeHeader works fine, but you fail to mention if you registered the hook? Adding the backOfficeHeader function alone is not enough, you need to register the function Link to comment Share on other sites More sharing options...
Newlifebeat1 Posted January 30, 2015 Share Posted January 30, 2015 Exactlly what i was thinking ... Link to comment Share on other sites More sharing options...
omine Posted March 23, 2015 Share Posted March 23, 2015 (edited) 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 March 23, 2015 by omine (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now