AdrianM2 Posted August 8, 2017 Share Posted August 8, 2017 Hi. I'm trying to add my custom .js file to one backed module. Any suggestions how to do this correctly? Tried adding: $this->output .= '<script type="text/javascript" src="../modules/'.$this->name.'custom.js"></script>'; in main .php module file between: public function getContent() { } and it's not working. Link to comment Share on other sites More sharing options...
BonPresta Posted August 17, 2017 Share Posted August 17, 2017 Hi. I'm trying to add my custom .js file to one backed module. Any suggestions how to do this correctly? Tried adding: $this->output .= '<script type="text/javascript" src="../modules/'.$this->name.'custom.js"></script>'; in main .php module file between: public function getContent() { } and it's not working. Hello, 1. register hook - displayBackOfficeHeader Example: public function install() { return parent::install() && $this->registerHook('header') && $this->registerHook('displayBackOfficeHeader') && $this->registerHook('displayHome'); } 2. Add js file custom.js Example: public function hookDisplayBackOfficeHeader() { if (Tools::getValue('configure') != $this->name) { return; } $this->context->controller->addJS($this->_path.'views/js/custom.js'); } 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