Jump to content

embed code below just before the closing </body> tag


janeklass

Recommended Posts

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

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

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

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

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

4 hours ago, rthakur said:

How to create custom js under theme

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)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...