{fetch} + CMS MS

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
User avatar
Cyc
Forum Members
Forum Members
Posts: 91
Joined: Wed Nov 18, 2015 11:54 pm
Location: Poland

{fetch} + CMS MS

Post 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?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1625
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: {fetch} + CMS MS

Post by DIGI3 »

You can set Permissive Smarty in your config:
https://docs.cmsmadesimple.org/configur ... ive_smarty
Not getting the answer you need? CMSMS support options
User avatar
Cyc
Forum Members
Forum Members
Posts: 91
Joined: Wed Nov 18, 2015 11:54 pm
Location: Poland

Re: {fetch} + CMS MS

Post by Cyc »

Thx for quick reply. Is this solution safe for production?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1625
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: {fetch} + CMS MS

Post 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.
Not getting the answer you need? CMSMS support options
User avatar
Cyc
Forum Members
Forum Members
Posts: 91
Joined: Wed Nov 18, 2015 11:54 pm
Location: Poland

Re: {fetch} + CMS MS

Post by Cyc »

Is there another, better, way to get content from my js file?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1625
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: {fetch} + CMS MS

Post 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.
Not getting the answer you need? CMSMS support options
User avatar
Cyc
Forum Members
Forum Members
Posts: 91
Joined: Wed Nov 18, 2015 11:54 pm
Location: Poland

Re: {fetch} + CMS MS

Post by Cyc »

Thx for help!
User avatar
Cyc
Forum Members
Forum Members
Posts: 91
Joined: Wed Nov 18, 2015 11:54 pm
Location: Poland

Re: {fetch} + CMS MS

Post by Cyc »

Ok, I try to use {cgjs_require jsfile="uploads/js/compsoul.js"} and content don't show up in template.
User avatar
Cyc
Forum Members
Forum Members
Posts: 91
Joined: Wed Nov 18, 2015 11:54 pm
Location: Poland

Re: {fetch} + CMS MS

Post by Cyc »

Ok, I have to use {cgjs_render} but what if I want to use code in <__script__></__script>?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1625
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: {fetch} + CMS MS

Post by DIGI3 »

Check the module's help under {cgjs_add [depends=mixed] [nominify=true]}...{/cgjs_add}
Not getting the answer you need? CMSMS support options
User avatar
Cyc
Forum Members
Forum Members
Posts: 91
Joined: Wed Nov 18, 2015 11:54 pm
Location: Poland

Re: {fetch} + CMS MS

Post 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?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1625
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: {fetch} + CMS MS

Post 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.
Not getting the answer you need? CMSMS support options
Post Reply

Return to “CMSMS Core”