Page 1 of 1
Can I generate Dynamic Script based on the template.
Posted: Thu Oct 08, 2015 11:58 am
by talnet
What I want to do is inject dynamic scripts based on the template and condition ( check from module config ). Is there any function I can for injecting into html like addScript in OpenCart ?
Re: Can I generate Dynamic Script based on the template.
Posted: Sat Oct 10, 2015 10:19 am
by straightlight
Could you provide an example of what you're trying to do, other than explaining the theory for instance? Your question may result countless solutions while all you may be looking for is a simple solution.
Re: Can I generate Dynamic Script based on the template.
Posted: Mon Oct 12, 2015 12:08 pm
by talnet
I am trying to develop a module which can do following things.
1. Will have an admin panel to set some variables
2. Will add a global script into every pages
3. Will generate a particular javascript on product/checkout pages based on the variables from backend.
Right now I successfully finished the dashboard part but I still can't figure out an API call to generate scripts into Open Cart's theme system.
Re: Can I generate Dynamic Script based on the template.
Posted: Mon Oct 12, 2015 8:25 pm
by straightlight
I would recommend the use of Ajax over PHP with JSON datatype rather than generic scripting from variables to form into JS. JSON datatype would avoid encountering XSS vulnerabilities.
Re: Can I generate Dynamic Script based on the template.
Posted: Thu Nov 23, 2017 10:05 pm
by straightlight
An addition with the help of this post:
viewtopic.php?f=121&t=199903#p704402 , the .htaccess file can also help to prevent XSS vulnerabiltiies with:
Code: Select all
<IfModule mod_headers.c>
# Set XSS Protection header
Header set X-XSS-Protection "1; mode=block"
</IfModule>