{fetch} + CMS MS
{fetch} + CMS MS
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?
{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
You can set Permissive Smarty in your config:
https://docs.cmsmadesimple.org/configur ... ive_smarty
https://docs.cmsmadesimple.org/configur ... ive_smarty
Not getting the answer you need? CMSMS support options
Re: {fetch} + CMS MS
Thx for quick reply. Is this solution safe for production?
Re: {fetch} + CMS MS
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.
Not getting the answer you need? CMSMS support options
Re: {fetch} + CMS MS
Is there another, better, way to get content from my js file?
Re: {fetch} + CMS MS
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.
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.
Not getting the answer you need? CMSMS support options
Re: {fetch} + CMS MS
Thx for help!
Re: {fetch} + CMS MS
Ok, I try to use {cgjs_require jsfile="uploads/js/compsoul.js"} and content don't show up in template.
Re: {fetch} + CMS MS
Ok, I have to use {cgjs_render} but what if I want to use code in <__script__></__script>?
Re: {fetch} + CMS MS
Check the module's help under {cgjs_add [depends=mixed] [nominify=true]}...{/cgjs_add}
Not getting the answer you need? CMSMS support options
Re: {fetch} + CMS MS
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
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.
You can file a feature request for CGExtensions to have it improved in the next release.
Not getting the answer you need? CMSMS support options