So this is basic and this could be done by these steps:
So fine, but what will you get if you publish your pages? Yep, a mess.
So what? You want to get the JS file outside of your HTML template and store it at ONE location on the webserver. Here’s how:
This should look like that:
Well done! Almost finished. Now you get the JS in two ways. You got the script block inside the HEAD-Tag and you got a link element which points to a page. But some fine tuning is still required:
Ok, that’s it, right? NO, it’s not. We still have both blocks and that means especially the <script> block inside our template, when pages get published. So what do else do we need?
A nifty reddot cms if-render tag to decide when to use what:
The first block is only executed on the CMS in preview and RedDot SmartEdit mode. The second one only when the page gets published.
I took this from one of my old reddot cms freelancer blog posts
Yeah, and I thought that’s it, great post. But then after thinking through and discussing it
with my other blog colleagues, Fred
“the awesome reddot geek” added another great idea.
Ok here we go, this is what you need, when you want to add more files in future: Make it a list.
And then you got this construct inside your template:
As you can see in the screenshot above you can do the same with CSS. Another idea is to move the whole construct out of your masterpage template and put it into an own template you use for CSS and JS. This template can be embedded in another container inside the masterpage template.
It’s important, that you reference from the container to the list as seen above in the screenshot. Otherwise the publication won’t work.
No related posts.