ooaykac
December 15, 2015, 12:00am
#1
Hi. I need to override core.js file in /js/tygh/ folder by using my addon.
I tried this:
/public_html/js/addons/my_addon/overrides/tygh/core.js But it didn't work.
Then I tried this:
/public_html/js/addons/my_addon/tygh/core.override.js
It also didn't work. What is the correct methos to do this?
SDAD
December 15, 2015, 12:00am
#2
There is no way to override js.
You can override tpl which includes this js.
Try overriding design/themes/[YOUR THEME]/templates/common/scripts.tpl
- Try to create the following file:
design/themes/YOUR_THEME/templates/addons/my_changes/overrides/common/scripts.tpl
- Copy the content of the design/themes/YOUR_THEME/templates/common/scripts.tpl file to it
- Replace:
{script src="js/tygh/core.js"}
with
{script src="js/addons/my_changes/core.override.js"}
- Clear cache and check the result
SDAD
December 15, 2015, 12:00am
#4
{ script src = "js/tygh/core.override.js" }
it should be in js/addons/[ADD-ON]/ folder
{script src="js/tygh/core.override.js"}
it should be in js/addons/[ADD-ON]/ folder
It should not, but this is right way. Corrected
SDAD
December 16, 2015, 12:00am
#6
Yes, it should not, but all add-on's js files are located there. Just for keeping order.
ooaykac, did our and simtedev's answer help you?
ooaykac
December 23, 2015, 12:00am
#8
Thanks to everyone. Yes, simtechdev's answer helped me. It works.
alaa
May 17, 2018, 12:00am
#9
There is no way to override js.
You can override tpl which includes this js.
Try overriding design/themes/[YOUR THEME]/templates/common/scripts.tpl
- Try to create the following file:
design/themes/YOUR_THEME/templates/addons/my_changes/overrides/common/scripts.tpl
- Copy the content of the design/themes/YOUR_THEME/templates/common/scripts.tpl file to it
- Replace:
{script src="js/tygh/core.js"}
with
{script src="js/addons/my_changes/core.override.js"}
- Clear cache and check the result
It should not, but this is right way. Corrected
Hi, I have a question regarding this. I want to edit one line in js\tygh\core.js
When we override this file in using tpl, does this mean that the new file core.override.js must contain all the functions on the original file core.js?
Can we override a specific function only instead of overriding the whole core.js file?
If not, What if future CS-Cart upgrades contain code modification/enhancements to this file. In this case, I will not get benefit from this as my file stays the same.
Can you please clarify?
Thanks!