LightlynX Posted November 24, 2016 Share Posted November 24, 2016 Hello fellows, I am having troubles getting our "old" plugin to work with the new Prestashop 1.7The method addJs doesn't include the scripts anymore and the new method registerJavascript doesn't allow urls e.g. cdnjsI solved it that I added the script tag to the template which is quite a bad practice, but I really didn't know how to work around it. Another issue is regarding the setForm in PaymentOption class. When I load the tplcontaining the form and add a listener to the form (onsubmit) then the form doesn't get submitted as the documentation says in the github. Does anybody have these issues too? Link to comment Share on other sites More sharing options...
phinq1910 Posted November 25, 2016 Share Posted November 25, 2016 Try using registerJavascript & registerStylesheet to set js or css file to templates $this->context->controller->registerStylesheet( 'module-mymodule-style', 'modules/'.$this->name.'/assets/css/my-popup.css', [ 'media' => 'all', 'priority' => 200, ] ); 1 Link to comment Share on other sites More sharing options...
LightlynX Posted November 25, 2016 Author Share Posted November 25, 2016 (edited) The method addJs doesn't include the scripts anymore and the new method registerJavascript doesn't allow urls e.g. cdnjs As you can see, I already mentioned that the method doesn't work with remote javascript e.g. cdnjs. It accepts only local scripts. Edited November 25, 2016 by LightlynX (see edit history) Link to comment Share on other sites More sharing options...
Arnaud Drieux Posted December 7, 2016 Share Posted December 7, 2016 Hello, I saw your post and im disapointed by new method which only accept local files.SoI use the inner template javascript method, but it's sure it's not the bes way Maybe prestashop needs to communicate on this problem... Link to comment Share on other sites More sharing options...
LightlynX Posted December 7, 2016 Author Share Posted December 7, 2016 Hello arnaud, ps 1.7.0.2 actually solves this problem. The developer named aleeks made a pull request which was merged few days ago and it does indeed support the remote resource loading. Have a look at http://stackoverflow.com/questions/40763815/add-remote-javascript-to-prestashop-1-7/41000834#41000834 Or to be more specific https://github.com/PrestaShop/PrestaShop/pull/7022 I hope this answer brings smile to all our faces 2 Link to comment Share on other sites More sharing options...
Andrej Stas Posted December 14, 2016 Share Posted December 14, 2016 Try using registerJavascript & registerStylesheet to set js or css file to templates $this->context->controller->registerStylesheet( 'module-mymodule-style', 'modules/'.$this->name.'/assets/css/my-popup.css', [ 'media' => 'all', 'priority' => 200, ] ); Thank you, phinq1910, that is the correct solution. I tried also the solution on StackOverflow: $this->registerJavascript('remote-bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', ['server' => 'remote', 'position' => 'bottom', 'priority' => 20]); But it doesn't work and I get PHP Fatal Error: Uncaught Error: Call to undefined method Ptm_Testimonials::registerJavascript() I run on Prestashop 1.7.0.2 Link to comment Share on other sites More sharing options...
LightlynX Posted December 14, 2016 Author Share Posted December 14, 2016 Thank you, phinq1910, that is the correct solution. I tried also the solution on StackOverflow: $this->registerJavascript('remote-bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', ['server' => 'remote', 'position' => 'bottom', 'priority' => 20]); But it doesn't work and I get PHP Fatal Error: Uncaught Error: Call to undefined method Ptm_Testimonials::registerJavascript() I run on Prestashop 1.7.0.2 Do you extend a controller? registerJavascript is a member of Controller class. Therefore you either extend some the controller class or you acquire your context and access its controller where you can acces the member method registerJavascript. e.g. $context = $this->getContext(); $context->controller->registerJavascript(...); I hope this clears something for you. 1 Link to comment Share on other sites More sharing options...
Madsex Posted April 27, 2017 Share Posted April 27, 2017 Hi i have a strange problem with registerStylesheet i set media => 'screen and (min-width:769px)' but the output continue to insert "all" and ignore my setting. Someone have noted this issue? Thanks, sorry about OT but apparently this thread is the only one on registerstylesheet 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