Add css and js in Controller - prestashop 1.7
Add CSS in controller.
// loaded css and js in module controller
public function setMedia() {
parent::setMedia();
$this->context->controller->registerStylesheet(‘affiliatestyle-css’,’modules/’.$this->module->name.’/css/affiliatestyle.css’,[‘media’ => ‘all’, ‘priority’ => 0]);
$this->context->controller->registerJavascript(‘sendtoafriend-js’,modules/’.$this->module->name.’/’sendtoafriend.js’,[‘position’ => ‘bottom’, ‘priority’ => 0]);
}
Add css and js in hook (header.Footer)
$this->context->controller->registerJavascript(‘sendtoafriend-js’,$this->_path.’/css/js/sendtoafriend.js’,[‘position’ => ‘bottom’, ‘priority’ => 0]);
$this->context->controller->registerStylesheet(‘sendtoafriend-css’,$this->_path.”/css/sendtoafriend.css’,[‘position’ => ‘bottom’, ‘priority’ => 0]);
Another way you can add csss and js in displayheader hook in module
public function hookDisplayHeader($params)
{
$this->context->controller->addCSS($this->_path.'css/xyz.css', 'all');
$this->context->controller->addJS($this->_path.'js/xyz.js');
}
Another way you can add csss and js in displayheader hook in module
public function hookDisplayHeader($params)
{
$this->context->controller->addCSS($this->_path.'css/xyz.css', 'all');
$this->context->controller->addJS($this->_path.'js/xyz.js');
}
Comments
Post a Comment