Why dont you just not use reddot for JS files?

In our projects we set up a virtual folder under the reddot website
and then just referance it that way, the only downside is you would
need to copy the JS/CSS files yourself but the benefits are that
designers can work on it outside of reddot.

For example in smart edit
Under the default website (on the CMS server where reddot gets its
files so it would be on teh same level as teh CMS virtual Dir) we
would have a virtual folder called ExternalFiles which would hold the
CSS and JS files.
In the template you would then just need to reference it as "/
externalfiles/file.js"

For Published Site
You would need to surround the referance with some reddot code (Which
is outlined above by gavin) so it would publish
the correct location. So say you copy the js file to your website
under the JS folder you would want the published location to be /JS/
file.js

This means that the users cant go into smart edit and change the
images used in teh css (breaking the site) and cuts down on assets
which are not needed.





On Mar 2, 10:56 pm, Gavin Cope <[email protected]> wrote:
> Use option 3, a combination of an anchor (published site) and a container
> (SmartEdit and Preview).
>
> <reddot:cms>
>     <if>
>         <query valuea="Context:CurrentRenderMode" operator="=="
> valueb="Int:2">
>             <htmltext>
>                 <script src="<%anc_javascript%>"
> type="text/javascript"></script>
>             </htmltext>
>         </query>
>         <query type="else">
>             <htmltext>
>                 <script type="text/javascript">
>                 <%con_javascript%>
>                 </script>
>             </htmltext>
>         </query>
>     </if>
> </reddot:cms>
>
> Then on both the content class instance and the content class itself,
> reference anc_javascript to con_javascript. That way your current and all
> future instances will automatically draw in the contents of anc_javascript
> to con_javascript. This method will also work just as well with a list
> placeholder in place of the anchor placeholder.
>
> This also gets around the issue whereby when switching between SmartEdit and
> SmartTree, the javascript "page" always gains focus in SmartTree instead of
> the actual page you were on.
>
> Cheers,
>
> Gavin
>
> 2009/3/3 fred2028 <[email protected]>
>
>
>
> > Hmmm I have tried #1. I appended it and SmartEdit the JS and CSS files
> > and View Source, and I can confirm that only the actual CSS/JS is
> > outside of comments so that works. However, after clearing page cache
> > and temporary IE 8 files, I SmartEdit again but no success. I now get
> > no JS error on 1 of my pages but otherwise no JS works.
>
> > For #2, shouldn't it be ?script=1 instead of &script=1 ? And I can
> > append that to a placeholder right in the template editor?
>
> > On Mar 2, 11:02 am, "[email protected]"
> > <[email protected]> wrote:
> > > Ahhh this is a common issue. When you're working in smartEdit RedDot
> > > looks for the <body>  tag so it can place some reddot code in there
> > > for the dots. If it can't find the body tag, it helpfully adds it for
> > > you as it adds in it's own code... instantly invalidating your code
> > > and causing all sorts of errors to appear. This will also be happening
> > > to your stylesheets; it just won't be as apparent.
>
> > > There are a couple of options to work around this :
>
> > > 1) In your JS files make the first line  /* <body></body> */ . This
> > > gives RedDot somewhere to put it's script so it doesn't break your
> > > project.
>
> > > or
>
> > > 2) In your link you can add a little bit of extra code so it looks
> > > like <script src="file.js<!IoRangeRedDotMode>&script=1</!
> > > IoRangeRedDotMode>" type="text/javascript"></script> This is supposed
> > > to tell RedDot to not append anything into the script file, but we've
> > > seen it cause other issues, especially when switching between
> > > smartEdit and smartTree.
>
> > > Finally the best option that we've come across...
>
> > > 3) In addition to your anchor you can set up a container in your
> > > template. Reference the container to your anchor so that the contents
> > > of your JS file appears in the container. Hide the container outside
> > > of RedDot and hide the anchor inside smartEdit so that it looks
> > > something like this :
>
> > > <!IoRangeNoRedDotMode>
> > >         <script src="file.js" type="text/javascript"></script>
> > > </!IoRangeNoRedDotMode>
> > > <!IoRangeRedDotMode>
> > >         <%cnt_javascript%>
> > > </!IoRangeRedDotMode>
>
> > > This has a double benefit. Your pages will no longer cause errors in
> > > smartEdit and you should also see a slight speed improvement for the
> > > editors as RedDot will be rendering one page instead of two each time
> > > a page is loaded.
>
> > > On 2 Mar 2009, at 15:27, fred2028 wrote:
>
> > > > In plain HTML:
>
> > > > <script src="file.js" type="text/javascript"></script>
>
> > > > In RedDot, I made a template of type JS and file extension JS, then
> > > > copied everything between <script type="text/javascript"> and </
> > > > script> into the content class template (much like how a traditional
> > > > JS file is made). In my foundation page that uses the JS, I made an
> > > > anchor placeholder and put it in place of file.js in the above
> > > > example. I made an instance of the JS content class and put the page
> > > > in clipboard, then referenced my anchor placeholder to this file.
> > > > However, this does not work, gives me JS errors when I SmartEdit, and
> > > > the page renders as if no JS is present.
>
> > > > What is the proper way to reference an external JS file without using
> > > > media placeholders?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"RedDot CMS Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/RedDot-CMS-Users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to