Page 1 of 1
{fetch} + CMS MS
Posted: Fri Dec 13, 2019 5:49 pm
by Cyc
I want to add my JS file local to template like this:
{fetch file="{root_url}/uploads/js/compsoul.js"}
In output I have: URI '
http://szablon.compsoul.pl/zero/uploads/js/compsoul.js' not allowed by security setting
Any ideas how can i resolve this problem?
Re: {fetch} + CMS MS
Posted: Fri Dec 13, 2019 5:54 pm
by DIGI3
Re: {fetch} + CMS MS
Posted: Fri Dec 13, 2019 5:58 pm
by Cyc
Thx for quick reply. Is this solution safe for production?
Re: {fetch} + CMS MS
Posted: Fri Dec 13, 2019 6:01 pm
by DIGI3
If you allow content from untrusted sources (frontend users, blog comments, etc) then you'll want to make sure you don't pass any of that through Smarty if you use this setting. If all content is from trusted sources it's not a problem.
Re: {fetch} + CMS MS
Posted: Fri Dec 13, 2019 6:06 pm
by Cyc
Is there another, better, way to get content from my js file?
Re: {fetch} + CMS MS
Posted: Fri Dec 13, 2019 6:13 pm
by DIGI3
Look at CGExtensions, and the {cgjs_include}, {cgjs_add}, and {cgjs_render} stuff. It's intended exactly for this.
It's especially good for adding js snippets from modules. Say you have a slider in LISE or Gallery, you could put the cgjs_include right in your slider template, cgjs_render in your master page template, then only pages calling the slider will load the script.
You can also use it for css but you'll need to make sure your css uses absolute paths for fonts/images as the css renders in tmp, not root.
Re: {fetch} + CMS MS
Posted: Fri Dec 13, 2019 6:15 pm
by Cyc
Thx for help!
Re: {fetch} + CMS MS
Posted: Fri Dec 13, 2019 9:47 pm
by Cyc
Ok, I try to use {cgjs_require jsfile="uploads/js/compsoul.js"} and content don't show up in template.
Re: {fetch} + CMS MS
Posted: Fri Dec 13, 2019 9:52 pm
by Cyc
Ok, I have to use {cgjs_render} but what if I want to use code in <__script__></__script>?
Re: {fetch} + CMS MS
Posted: Fri Dec 13, 2019 10:00 pm
by DIGI3
Check the module's help under {cgjs_add [depends=mixed] [nominify=true]}...{/cgjs_add}
Re: {fetch} + CMS MS
Posted: Mon Dec 16, 2019 8:17 pm
by Cyc
Ok looks fine, but after render I have error in W3C "The type attribute is unnecessary for JavaScript resources." how to replace type in script mark?
Re: {fetch} + CMS MS
Posted: Mon Dec 16, 2019 8:50 pm
by DIGI3
That's just a notice, not an error (the use of 'type' is deprecated, but not problematic).
You can file a feature request for CGExtensions to have it improved in the next release.