Inform-All Posted September 2, 2020 Share Posted September 2, 2020 (edited) I'm making a custom module for a customer, and for this module i use the "displayAdminProductsOptionsStepTop" hook. I successfully added my custom css and js like this: public function hookactionAdminControllerSetMedia($params) { $this->context->controller->addJS($this->_path.'/views/js/customJSfile.js'); $this->context->controller->addCSS($this->_path.'/views/css/customCSSfile.css'); } The problem It loads this js and css file in every backend page, and this gives some conflicts. Is there a proper way to load the js/css only for the AdminProducts page? Edited September 2, 2020 by Inform-All (see edit history) Link to comment Share on other sites More sharing options...
Matt75 Posted September 2, 2020 Share Posted September 2, 2020 See https://devdocs.prestashop.com/1.7/modules/creation/good-practices/ Just add a condition to target only AdminProduct controller Link to comment Share on other sites More sharing options...
Inform-All Posted September 2, 2020 Author Share Posted September 2, 2020 For other PS users, not a pretty solution, but it works: public function hookactionAdminControllerSetMedia($params) { if ($this->context->controller->php_self === "AdminProducts") { $this->context->controller->addJS($this->_path.'/views/js/customJSfile.js'); $this->context->controller->addCSS($this->_path.'/views/css/customCSSfile.css'); } } 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