janeklass Posted November 28, 2022 Share Posted November 28, 2022 Hi, I'm trying to get a popup solution to work, for that I need to add a small piece of code before the closing </body> tag. I don't understand exactly where and how to add it? Is there any additional module needed for this, or does it have to be added somewhere in the presta code? The code snippet itself is like this: <script src="https://cdn.popupsmart.com/bundle.js" data-id="6660" async defer></script> Thnx Jane Link to comment Share on other sites More sharing options...
rthakur Posted November 28, 2022 Share Posted November 28, 2022 Hola, La función addJS() está obsoleta en PrestaShop 1.7. Ahora debe usar registerJavascript(). $this->context->controller->registerJavascript( 'monurl', 'https://cdn.popupsmart.com/bundle.js', array('server' => 'remote', 'position' => 'bottom', 'priority' => 150)); El argumento importante que no debe olvidar aquí es 'servidor' => 'remoto' para cargar un archivo JS externo. Puede encontrar más información sobre esta función aquí en el documento: https://developers.prestashop.com/themes/assets/index.html Otro pensamiento sobre su código, no tiene que poner: si (!$esto->activo) devolver; No se llamará al enlace completo si el módulo está deshabilitado. Link to comment Share on other sites More sharing options...
webprog Posted November 28, 2022 Share Posted November 28, 2022 You can use footer file. For classic theme path is themes\classic\templates\_partials\footer.tpl But it is not clean way. Better to use hooks in modules. Link to comment Share on other sites More sharing options...
janeklass Posted November 28, 2022 Author Share Posted November 28, 2022 1 hour ago, webprog said: You can use footer file. For classic theme path is themes\classic\templates\_partials\footer.tpl But it is not clean way. Better to use hooks in modules. Ok, But what module could be suitable? I tried a custom css and js module, but it broke the page when I added the code to the js box and activated it. Link to comment Share on other sites More sharing options...
webprog Posted November 28, 2022 Share Posted November 28, 2022 30 minutes ago, janeklass said: Ok, But what module could be suitable? I tried a custom css and js module, but it broke the page when I added the code to the js box and activated it. You can use your module, but insert js into code of the module before that. Link to comment Share on other sites More sharing options...
rthakur Posted November 28, 2022 Share Posted November 28, 2022 41 minutes ago, janeklass said: Ok, But what module could be suitable? I tried a custom css and js module, but it broke the page when I added the code to the js box and activated it. Donot use module you just can create custom.js and put js code to custom.js Link to comment Share on other sites More sharing options...
rthakur Posted November 28, 2022 Share Posted November 28, 2022 How to create custom js under theme 125354584_Screencastfrom11-28-2022034559PM.webm Link to comment Share on other sites More sharing options...
janeklass Posted November 28, 2022 Author Share Posted November 28, 2022 4 hours ago, rthakur said: How to create custom js under theme 125354584_Screencastfrom11-28-2022034559PM.webm Ok, thanks. Am I understanding correctly that I need to find my theme custom .js and add the code there? I already have a lot of custom js code, where exactly do I need to add my code to make it work? (see video) 20221128_170954.mp4 Link to comment Share on other sites More sharing options...
janeklass Posted November 28, 2022 Author Share Posted November 28, 2022 I found a solution. The code had to be added to the layout-both-columns.tpl file Link to comment Share on other sites More sharing options...
rthakur Posted November 28, 2022 Share Posted November 28, 2022 28 minutes ago, janeklass said: I found a solution. The code had to be added to the layout-both-columns.tpl file Great 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