Kathleen86 Posted January 21, 2021 Share Posted January 21, 2021 Hello everybody, The CSS and JS are not taken into account in my front controller module. What could I do ? Thank's in advance for your help. Here is the code of the method setmedia: public function setMedia() { parent::setMedia(); $this->registerStylesheet( 'localhost/softage/modules/aeccollaborators/views/css/my-collaborator.css', [ 'media' => 'all', 'priority' => 200, ] ); $this->registerJavascript( 'localhost/softage/modules/aeccollaborators/views/js/my-collaborator.js', [ 'priority' => 200, 'attribute' => 'async', ] ); } Link to comment Share on other sites More sharing options...
Rhobur Posted January 23, 2021 Share Posted January 23, 2021 (edited) For PS 1.7+ use this hook in your module's main class: public function hookActionFrontControllerSetMedia() { Media ::addJsDef([ 'your_module_name' => $this -> context -> link -> getModuleLink($this -> name, 'display', [], true), ]); $this -> context -> controller -> registerJavascript('modules-your_module_name', 'modules/' . $this -> name . '/views/js/front.js'); } It also works with hookHeader(). Edited January 23, 2021 by Rhobur (see edit history) Link to comment Share on other sites More sharing options...
Kathleen86 Posted January 25, 2021 Author Share Posted January 25, 2021 Thank's a lot ! 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