Trying to permanently add a script to my header.twig file, but changes to this file don't appear on the website (even though they are actually saved to the file). I figured that the file has been modified by multiple extensions. The only way to get my script to appear is temporarily by adding it to the storage/modification directory version of the file. Refreshing my modifications cache in this case, will undo all changes to this file.
Is there any way to get my script into the header.twig file permanently?
As the original file doesn't change anything and the modded file is only temporarily.
Many thanks in advance!
OC 3.0.3.2
Is there any way to get my script into the header.twig file permanently?
As the original file doesn't change anything and the modded file is only temporarily.
Many thanks in advance!
OC 3.0.3.2
Last edited by Dutch Pride Code on Thu Nov 17, 2022 11:12 pm, edited 1 time in total.
Correct way to add script to template is to use folowing PHP-code in a controller:
$this->document->addScript('....URL of script.....');
$this->document->addScript('....URL of script.....');
Thanks. How would you implement that when using a third party inline script, like Google Analytics for example? Just put the script into a separate file and link that file instead?toporchillo wrote: ↑Mon Nov 14, 2022 9:18 pmCorrect way to add script to template is to use folowing PHP-code in a controller:
$this->document->addScript('....URL of script.....');
It depends on third-party script accessibility.EMGX wrote: ↑Mon Nov 14, 2022 9:29 pmThanks. How would you implement that when using a third-party inline script, like Google Analytics for example? Just put the script into a separate file and link that file instead?toporchillo wrote: ↑Mon Nov 14, 2022 9:18 pmCorrect way to add script to template is to use folowing PHP-code in a controller:
$this->document->addScript('....URL of script.....');
Google Analytics is better to add as an external resource. Client's web browser probably already stores it in its cache. And it doesn't need to download again.
Add it to the header.twig file and refresh the cacheEMGX wrote: ↑Mon Nov 14, 2022 8:48 pmTrying to permanently add a script to my header.twig file, but changes to this file don't appear on the website (even though they are actually saved to the file). I figured that the file has been modified by multiple extensions. The only way to get my script to appear is temporarily by adding it to the storage/modification directory version of the file. Refreshing my modifications cache in this case, will undo all changes to this file.
Is there any way to get my script into the header.twig file permanently?
As the original file doesn't change anything and the modded file is only temporarily.
Many thanks in advance!
OC 3.0.3.2
Mike
cue4cheap not cheap quality
That's the point, changes won't appear at all if I do that. The changes only appear when I use the modded file (in system/modifications directory), but then it will undo as soon as I refresh my modification cache.
You have to be doing something in the wrong file or something wrong. If you enter in a single letter or character at the top of the header.twig file and refresh, does it show?
Mike
cue4cheap not cheap quality
I've tried adding characters and they don't show either, so I think you're right. But I have no clue what other file to look at. There is only one header.twig file here, and the modified version of this exact file (in system/modification directory) does show all changes. This file does represent the original file in the same directory, right?Cue4cheap wrote: ↑Mon Nov 14, 2022 10:31 pmYou have to be doing something in the wrong file or something wrong. If you enter in a single letter or character at the top of the header.twig file and refresh, does it show?
Mike
Thanks for your help though. How do I find out what file to look for?
Easiest way to add such, is to use the default analytics extension Google AnalyticsEMGX wrote: ↑Mon Nov 14, 2022 8:48 pmTrying to permanently add a script to my header.twig file, but changes to this file don't appear on the website (even though they are actually saved to the file). I figured that the file has been modified by multiple extensions. The only way to get my script to appear is temporarily by adding it to the storage/modification directory version of the file. Refreshing my modifications cache in this case, will undo all changes to this file.
Is there any way to get my script into the header.twig file permanently?
As the original file doesn't change anything and the modded file is only temporarily.
Just add there want you need ..
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Google Analytics was just an example. I'm using different scripts that are used in the exact same way (inline, copy paste). Can I use the extension for those as well? As it basically just puts the script in the head tag?
You have to look to see if you are using the correct header file.
There is no way, if you are adjusting the correct file and then refreshing the caches, that it wouldn't show some simple text. I usually put in 3 dots just because it is something unique and searchable on the front end but also not obtrusive.
From this thread I am guessing you are using the default theme? If not, then please ensure there is only 1 header file.
Mike
There is no way, if you are adjusting the correct file and then refreshing the caches, that it wouldn't show some simple text. I usually put in 3 dots just because it is something unique and searchable on the front end but also not obtrusive.
From this thread I am guessing you are using the default theme? If not, then please ensure there is only 1 header file.
Mike
cue4cheap not cheap quality
By using a /after event. Few examples can be used from your catalog/controller/extension/advertise/google.php file and the oc_event table on the database.EMGX wrote: ↑Mon Nov 14, 2022 9:29 pmThanks. How would you implement that when using a third party inline script, like Google Analytics for example? Just put the script into a separate file and link that file instead?toporchillo wrote: ↑Mon Nov 14, 2022 9:18 pmCorrect way to add script to template is to use folowing PHP-code in a controller:
$this->document->addScript('....URL of script.....');
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Yes, you can (several clients of me are working that way .. ).
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Many thanks, I got it working now!OSWorX wrote: ↑Tue Nov 15, 2022 5:17 amYes, you can (several clients of me are working that way .. ).
Who is online
Users browsing this forum: No registered users and 20 guests