fransjaeger Posted January 28, 2015 Share Posted January 28, 2015 Hi there I have managed to include css an js files, BUT its included using hookDisplayHeader() That means its included on all pages and slowing my pages. How can I include my css and js fils ONLY on the relevant pages? Module is placed here on github Thanks in advance Link to comment Share on other sites More sharing options...
vekia Posted January 28, 2015 Share Posted January 28, 2015 you have to add php condition to check on what pages customer is. for exmaple: if (Tools::getValue('controller','false') != 'false'){ if (Tools::getValue('controller') == 'product'){ // HERE CODE TO ADD CSS OR JS } } 1 Link to comment Share on other sites More sharing options...
fransjaeger Posted January 28, 2015 Author Share Posted January 28, 2015 Cool! off course! Thanks Vekia I got a suplymentary question But what would i have to do with my hooks? Is there a way to put something inside here, that includes the the css/js files when a hook is executed Link to comment Share on other sites More sharing options...
vekia Posted January 28, 2015 Share Posted January 28, 2015 have you tried to add $this->context->controller->addCSS($this->_path . 'views/css/css.css', 'all'); $this->context->controller->addJS($this->_path . 'views/js/bookmark.js'); in this hook? i remember that in prestashop 1.4 there was a problem with including js css libraries in other hooks than hookHeader but now, in ps 1.6 you shouldn't have this problem Link to comment Share on other sites More sharing options...
fransjaeger Posted January 28, 2015 Author Share Posted January 28, 2015 have you tried to add $this->context->controller->addCSS($this->_path . 'views/css/css.css', 'all'); $this->context->controller->addJS($this->_path . 'views/js/bookmark.js'); in this hook? i remember that in prestashop 1.4 there was a problem with including js css libraries in other hooks than hookHeader but now, in ps 1.6 you shouldn't have this problem Yes I have tried that, and I just tried it again, but for some reason it doesnt load them. It only works for me when I put it inside the hookDisplayHeader() I cant grasp what Im doing wrong, cause i've seen that how it can be done, like you suggest. Link to comment Share on other sites More sharing options...
fransjaeger Posted January 29, 2015 Author Share Posted January 29, 2015 Im sometimes wondering... are you and al capone (el patron) the only active people in here? 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