iGalerie

Vous n'êtes pas identifié(e).

Annonce

Un message d'erreur qui s'affiche ? Un mot de passe oublié ? L'ajout de fichier qui ne marche pas ?
Pensez d'abord à lire la FAQ, vous y trouverez probablement une solution à votre problème.

#1 26-03-2024 21:46:57

Knut
Membre
Lieu : Norway
Inscription : 27-12-2013
Messages : 74
Site Web

javascript in head.tpl.php

I have successfully used the head.tpl.php file under Template/Default/Custom to run a separate JavaScript menu for a sister-website with  the album.
This has worked well until version igalerie 3.0.22. But in 3.0.23 I cannot get it to work. The menu does not show at all.
Suggestions appreciated.
Knut

Hors ligne

#2 27-03-2024 10:32:25

David
Développeur d'iGalerie
Inscription : 12-05-2006
Messages : 4 337
Site Web

Re : javascript in head.tpl.php

Hi,

Security is one of the improvements in the latest version, particularly in terms of HTTP headers to protect the application from XSS attacks. To add Javascript code, use one of the following two methods:

With a "nonce":

<script nonce="<?php echo CSP_NONCE; ?>" type="text/javascript">

</script>

With a file (for example: "custom.js" in the "js" directory):

<script type="text/javascript" src="<?php echo $tpl['gallery']['path']; ?>/js/custom.js"></script>

Hors ligne

#3 27-03-2024 22:51:42

Peter Martin
Membre
Inscription : 26-03-2024
Messages : 4

Re : javascript in head.tpl.php

Might this be related to why the slideshow stopped working after I upgraded? Ditto for the modals (login, edit icon, etc.).

Dernière modification par Peter Martin (27-03-2024 23:28:17)

Hors ligne

#4 07-04-2024 16:39:45

Knut
Membre
Lieu : Norway
Inscription : 27-12-2013
Messages : 74
Site Web

Re : javascript in head.tpl.php

Hi David,
Thanks for the input.

I added the
nonce="<?php echo CSP_NONCE; ?>"

to my menu script lines to the head.tpl.php file in template/default/custom folder.
The scripts load correctly (I checked see the page source), but the menus did not show up.

The second method, I may have misunderstood the use the correct procedure:
I loaded this line in template/default/custom/head.tpl.php
<script type="text/javascript" src="<?php echo $tpl['gallery']['path']; ?>/js/custom.js"></script>

Then I made the script lines in to js/custom.js (in js root folder)
This does not load the script at all.
Knut

Dernière modification par Knut (07-04-2024 16:39:55)

Hors ligne

Pied de page des forums