Azariil Posted August 22, 2017 Share Posted August 22, 2017 (edited) Hello everybody! I use a third-party template. In this template, there is a hook on the SMS page for outputting third-party content. I want to add my own CSS file when outputting content. For this I use the following code: $this->context->controller->registerStylesheet( 'module-mymodule-style', 'modules/'.$this->name.'/views/css/mystyle.css', [ 'media' => 'all', 'priority' => 200, ] ); But on the page the file is not added. But if I display a list of СSS files on the screen, then my file is there. $this->context->smarty->assign('mydebug', $this->context->controller->getStylesheets()); <pre>{$mydebug|print_r}</pre> Tell me, please, how can I add my СSS file correctly to the page? Thank you! UPD: I forgot to write that I use Prestashop 1.7.2 Edited August 22, 2017 by Azariil (see edit history) Link to comment Share on other sites More sharing options...
Azariil Posted August 22, 2017 Author Share Posted August 22, 2017 (edited) I tried the example from the documentation, but it also did not work. public function hookActionFrontControllerSetMedia($params) { $this->context->controller->registerStylesheet( 'module-mymodule-style', 'modules/'.$this->name.'/views/css/styles.css', [ 'media' => 'all', 'priority' => 200, ] ); } Edited August 22, 2017 by Azariil (see edit history) Link to comment Share on other sites More sharing options...
Azariil Posted August 24, 2017 Author Share Posted August 24, 2017 Alas, I still could not find a solution. I had to use the inline styles and output them through a template variable. If someone knows the solution to the problem, then please tell me, because I want to write the code correctly and beautifully . Link to comment Share on other sites More sharing options...
Zohaib-fk Posted August 25, 2017 Share Posted August 25, 2017 (edited) Hi, I have added folders in my module views/css and inside module php wrote below code. $this->context->controller->addCSS($this->_path.'views/css/cssfilename.css'); This includes css file when I load my module in front-office. Another way to do it like below function in module php file. PrestaShop Tutorials Videos [How to do Tasks] https://www.prestashop.com/forums/topic/907438-prestashop-tutorials-videos-how-to-do-tasks/ public function hookHeader ($ params) { $this->context->controller->addJS($this->_path.'views/js/jsfilename.js'); $this->context->controller->addCSS($this->_path.'views/css/cssfilename.css'); } Edited June 30, 2021 by Zohaib-fk Post Updated (see edit history) 2 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