Jump to content

prestashop add js and css in a module


Recommended Posts

Hi,

 

I am just a newbie to the prestashop. I am doing a module from scratch. In the module I need to add some link to css and js file. For that I have used

 

Tools::addcss(($this->_path).'css/search.css', 'all');
   Tools::addjs(($this->_path).'js/search.js', 'all');

 

and this one is working fine but there is one error telling that

Warning: Function addCSS() is deprecated

. So I checked for some documentation and got something to work. So I used

$this->context->controller->addjs('js/search.js', 'all'); 

but this one is not working at all. So can someone kindly tell me how to solve this issue? Any help and suggestions will be really appreciable. Thanks

Link to comment
Share on other sites

  • 1 year later...

here is my code (prestashop 1.6),but my css is not run,pls explain help me why did ?

public function hookHeader($params)
    {
        if (isset($this->context->controller->php_self) && $this->context->controller->php_self == 'index')
            $this->context->controller->addCSS(_THEME_CSS_DIR_.'product_list.css');
            $this->context->controller->addCSS($this->_path.'css/npt.css', 'all');
        
    }

Link to comment
Share on other sites

×
×
  • Create New...