How to add a part of code just before closing body tag in template for Joomla 4?

michal84
143 Posts
michal84 posted this 03 October 2023
Ask a Question

Hello Nicepage team,
can you please give me a tip, on where and how to edit my template, so that before closing body tag is NOT injected any other part of the template or Nicepage editor?

I need to be sure, that such part of the code will be on each page, where my template is used (blog, e-shop, login screen, page not found, etc....).

Even if I place anything just above the (index.php), there is still being added some Nicepage container. I need to be sure, that my JS will be placed as the last content before closing the body tag. Thanks for your ideas on how to do it.

Joomla! 4.3.4

Hello Nicepage team, can you please give me a tip, on where and how to edit my template, so that before closing body tag is NOT injected any other part of the template or Nicepage editor? I need to be sure, that such part of the code will be on each page, where my template is used (blog, e-shop, login screen, page not found, etc....). Even if I place anything just above the (index.php), there is still being added some Nicepage container. I need to be sure, that my JS will be placed as the last content before closing the body tag. Thanks for your ideas on how to do it. Joomla! 4.3.4
Vote to pay developers attention to this features or issue.
7 Replies
Order By: Standard | Newest
Support Team
Support Team posted this 03 October 2023

Hello Michal,
Thanks for choosing Nicepage!

HTML control allows adding custom HTML to any place in the BODY. I suggest that you try this control for adding code to the end of the BODY too. You cannot add custom code right before the closing tag. But I suggest that you add HTML control to the Footer. This should work too.

...................................................
Sincerely,
Negat Veri
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Hello Michal, Thanks for choosing Nicepage! HTML control allows adding custom HTML to any place in the BODY. I suggest that you try this control for adding code to the end of the BODY too. You cannot add custom code right before the closing tag. But I suggest that you add HTML control to the Footer. This should work too. ................................................... Sincerely, Negat Veri Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
michal84
143 Posts
michal84 posted this 04 October 2023

Hello Negat,
thanks for your answer. I tried that yesterday, and it was placed not just before the body tag, but before some div container.

Is there any JS, that generates that div container, where it would be possible to place custom code?
I need to place some JS for the affiliate site just before the end of body.

Thanks,
Michal

Hello Negat, thanks for your answer. I tried that yesterday, and it was placed not just before the body tag, but before some div container. Is there any JS, that generates that div container, where it would be possible to place custom code? I need to place some JS for the affiliate site just before the end of body. Thanks, Michal
Support Team
Support Team posted this 04 October 2023

Hi Michal,

There is o such possibility to add the code right before the closing tag, but I'm sure that the code should be working fine in any other place on the site also.

...................................................
Sincerely,
Hella
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Hi Michal, There is o such possibility to add the code right before the closing tag, but I'm sure that the code should be working fine in any other place on the site also. ................................................... Sincerely, Hella Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
michal84
143 Posts
michal84 posted this 04 October 2023

Hello Hella,
this is unfortunately not accepted by the aff. company. They asked me to place their code just before the closing body tag.

In other locations of the template, it works fine without any issues.

Best,
Michal

Hello Hella, this is unfortunately not accepted by the aff. company. They asked me to place their code just before the closing body tag. In other locations of the template, it works fine without any issues. Best, Michal
Support Team
Support Team posted this 04 October 2023

Hi Michal,

We are sorry but Nicepage does not provide such a functionality. You can try to edit the theme files manually after the export but we do not support such custom modifications.

...................................................
Sincerely,
Hella
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Hi Michal, We are sorry but Nicepage does not provide such a functionality. You can try to edit the theme files manually after the export but we do not support such custom modifications. ................................................... Sincerely, Hella Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
michal84
143 Posts
michal84 posted this 04 October 2023

I see Hella.
That is what I did yesterday. No matter in which template file I placed the code (the code was placed always just before the closing body tag), always was before the closing body tag placed some nicepage div, which was not visible in the edited exported template files. That's why, I am asking, which file is the last div with nicepage in its name read from.

As it had Nicepage in its class name, I assume, it does not have anything to do with CMS itself.

Best,
Michal

I see Hella. That is what I did yesterday. No matter in which template file I placed the code (the code was placed always just before the closing body tag), always was before the closing body tag placed some nicepage div, which was not visible in the edited exported template files. That's why, I am asking, which file is the last div with nicepage in its name read from. As it had Nicepage in its class name, I assume, it does not have anything to do with CMS itself. Best, Michal
Support Team
Support Team posted this 10 October 2023

Hello Michal,

We understand you want to add a piece of JS code just before the closing tag in your Joomla 4 template. However, based on the provided information and the responses you received on the Nicepage forum, Nicepage doesn't provide a direct feature for inserting code in that specific location.

While it's common to add JavaScript code just before the tag for various purposes, it appears that Nicepage adds its own containers or elements during the export process, which can interfere with your custom placement.

As a workaround, you might consider editing the template files manually after the export. However, please note that this is a custom modification, and Nicepage doesn't officially support such modifications.

Here are some steps you can try out:

  1. Export your Joomla 4 template using Nicepage.

  2. Locate the exported template files on your local system.

  3. Open the file (index.php) for your template in a code editor.

  4. Navigate to the bottom of the file, just before the closing tag.

  5. Add your custom JavaScript code there.

  6. Save the changes to the file.

  7. Upload the modified file to your Joomla 4 Template installation, replacing the original one.

Remember that this approach may require you to manually update the custom code if you make changes to your template using Nicepage and re-export it in the future.

Please proceed cautiously and make backups of your template and website files before making any modifications.

If you have further questions or need additional assistance, please feel free to ask.
...................................................
Sincerely,
Ahmad.
Nicepage Support Team

Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1
Follow us on Facebook: http://facebook.com/nicepageapp

Hello Michal, We understand you want to add a piece of JS code just before the closing </body> tag in your Joomla 4 template. However, based on the provided information and the responses you received on the Nicepage forum, Nicepage doesn't provide a direct feature for inserting code in that specific location. While it's common to add JavaScript code just before the </body> tag for various purposes, it appears that Nicepage adds its own containers or elements during the export process, which can interfere with your custom placement. As a workaround, you might consider editing the template files manually after the export. However, ***please note that this is a custom modification, and Nicepage doesn't officially support such modifications.*** Here are some steps you can try out: 1. Export your Joomla 4 template using Nicepage. 2. Locate the exported template files on your local system. 3. Open the file (index.php) for your template in a code editor. 4. Navigate to the bottom of the file, just before the closing </body> tag. 5. Add your custom JavaScript code there. 6. Save the changes to the file. 7. Upload the modified file to your Joomla 4 Template installation, replacing the original one. Remember that this approach may require you to manually update the custom code if you make changes to your template using Nicepage and re-export it in the future. Please proceed cautiously and make backups of your template and website files before making any modifications. If you have further questions or need additional assistance, please feel free to ask. ................................................... Sincerely, Ahmad. Nicepage Support Team Please subscribe to our YouTube channel: http://youtube.com/nicepage?sub_confirmation=1 Follow us on Facebook: http://facebook.com/nicepageapp
You must log in or register to leave comments