Page 1 of 1

How to add Javascript with Journal theme?

Posted: Sat Dec 08, 2018 5:36 pm
by stashdesign
I am trying to add this javascript to my Opencart page, i am on version 3.0.2.0 and using the Journal Theme. I have tried to add the code in Journal's "Custom JS" section with no success. I have also tried to add the script inside a new .js file and insert the code $this->document->addScript('catalog/view/javascript/xxxx.js'); into the header controller, also with no success.

Someone please help me with a solution for this to work?

Script:
<script> (function() { var s = document.createElement('script'); s.async = true; s.src = 'https://cdn.listagram.com/static/api/listagram.js'; document.body.appendChild(s); window.LISTAGRAM_CFG = { 'token': '9753f621-7ef4-4199-a23e-ff6b272de16e', 'base_media': 'https://cdn.listagram.com/media/', 'base_static': 'https://cdn.listagram.com/static/', 'base_api': 'https://www.listagram.com/api/', }; }());</script>

Re: How to add Javascript with Journal theme?

Posted: Sun Dec 09, 2018 6:25 pm
by xxvirusxx
stashdesign wrote:
Sat Dec 08, 2018 5:36 pm
I have also tried to add the script inside a new .js file and insert the code $this->document->addScript('catalog/view/javascript/xxxx.js'); into the header controller
And after that you have refreshed ocmod?
Cleared theme cache, SASS Cache (from Dashboard, top right)

Re: How to add Javascript with Journal theme?

Posted: Sun Dec 09, 2018 7:52 pm
by stashdesign
xxvirusxx wrote:
Sun Dec 09, 2018 6:25 pm
stashdesign wrote:
Sat Dec 08, 2018 5:36 pm
I have also tried to add the script inside a new .js file and insert the code $this->document->addScript('catalog/view/javascript/xxxx.js'); into the header controller
And after that you have refreshed ocmod?
Cleared theme cache, SASS Cache (from Dashboard, top right)
Yes, i have cleared all cache and refreshed ocmod :)

Re: How to add Javascript with Journal theme?

Posted: Sun Dec 09, 2018 8:30 pm
by xxvirusxx
Use View source to see if you script is loaded.

Re: How to add Javascript with Journal theme?

Posted: Sun Dec 09, 2018 9:28 pm
by stashdesign
xxvirusxx wrote:
Sun Dec 09, 2018 8:30 pm
Use View source to see if you script is loaded.
Can find it the chrome console, but not in "View source". Strange, the script working perfect with my another WooCommerce shop, but not with opencart.

Re: How to add Javascript with Journal theme?

Posted: Sun Dec 09, 2018 10:11 pm
by xxvirusxx
Try to add in you journal header.twig

Code: Select all

<script src="catalog/view/javascript/you_file.js" type="text/javascript"></script>

Re: How to add Javascript with Journal theme?

Posted: Mon Dec 10, 2018 2:38 am
by stashdesign
xxvirusxx wrote:
Sun Dec 09, 2018 10:11 pm
Try to add in you journal header.twig

Code: Select all

<script src="catalog/view/javascript/you_file.js" type="text/javascript"></script>
Unfortently, no success :(