prestahench Posted May 25, 2017 Share Posted May 25, 2017 Hello I'm trying to create my first custom module and I need to add stylesheet and some scripts that I have inside the module. The folder stucture is the following: verticalsidemenu --css --img --js -logo.png -verticalsidemenu.php -verticalsidemenu.tpl This is my php file: https://pastebin.com/Fp3p95Ww In the line "missing styles" I tried adding both setMedia and-or hookActionFrontControllerSetMedia as listed in this page: http://developers.prestashop.com/themes/assets/index.html But looks like I can't succeed to include my styles Can you tell me exactly where I should write the code in that file? Should I use setMedia or hookActionFrontControllerSetMedia All this module does is adding a vertical static menu, right now to proceed I had to hardcode the link to my stylesheet in header.tpl of my theme Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted May 25, 2017 Share Posted May 25, 2017 Hello I'm trying to create my first custom module and I need to add stylesheet and some scripts that I have inside the module. The folder stucture is the following: verticalsidemenu --css --img --js -logo.png -verticalsidemenu.php -verticalsidemenu.tpl This is my php file: https://pastebin.com/Fp3p95Ww In the line "missing styles" I tried adding both setMedia and-or hookActionFrontControllerSetMedia as listed in this page: http://developers.prestashop.com/themes/assets/index.html But looks like I can't succeed to include my styles Can you tell me exactly where I should write the code in that file? Should I use setMedia or hookActionFrontControllerSetMedia All this module does is adding a vertical static menu, right now to proceed I had to hardcode the link to my stylesheet in header.tpl of my theme Hi..use your css inside header hook insted of install hook. $this->registerHook('header') public function hookHeader() { $this->context->controller->addCSS($this->_path . 'css/style.css', 'all');//path of css } Thanks 1 Link to comment Share on other sites More sharing options...
prestahench Posted May 26, 2017 Author Share Posted May 26, 2017 Hi..use your css inside header hook insted of install hook. $this->registerHook('header') public function hookHeader() { $this->context->controller->addCSS($this->_path . 'css/style.css', 'all');//path of css } Thanks Thank you very much!! It works! Now I have the same problem with javascript file actually... I tried simply to add it to the header hook but it doesn't work, like this: public function hookHeader() { $this->context->controller->addCSS($this->_path . 'css/style.css', 'all'); $this->context->controller->registerJavascript(.$this->name.'/js/script.js') } Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted May 26, 2017 Share Posted May 26, 2017 Hi.same as css include like this public function hookHeader() { $this->context->controller->addCSS($this->_path . 'css/style.css', 'all');//path of css $this->context->controller->addJS($this->_path . 'js/script.js');//path of js } Thanks 1 Link to comment Share on other sites More sharing options...
prestahench Posted May 26, 2017 Author Share Posted May 26, 2017 Hi. same as css include like this public function hookHeader() { $this->context->controller->addCSS($this->_path . 'css/style.css', 'all');//path of css $this->context->controller->addJS($this->_path . 'js/script.js');//path of js } Thanks It works! Thank you very much for the help man! Link to comment Share on other sites More sharing options...
batranom Posted August 19, 2018 Share Posted August 19, 2018 I have same problem and I did the same but it do not work for me Any ideas? Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted August 20, 2018 Share Posted August 20, 2018 On 8/19/2018 at 6:11 AM, batranom said: I have same problem and I did the same but it do not work for me Any ideas? can you register "header" hook in module install method ? Link to comment Share on other sites More sharing options...
Sasni Posted June 26, 2022 Share Posted June 26, 2022 addCSS @deprecated 1.7 This function shouldn't be used, use $this->registerStylesheet() instead addJS @deprecated 1.7 This function has no effect in PrestaShop 1.7 theme, use $this->registerJavascript() 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