Solved

Including CSS files from outside the wwwroot in Coldfusion

Posted on 2013-01-23
8
449 Views
Last Modified: 2013-01-23
I have looked all over the internet for this answer and can not find one solution that works with CSS file. I am trying to include css files from outside the wwwroot folder. How can I do this? I am hosting my site on Hostek Coldfusion servers.
0
Comment
Question by:Envisoin
  • 3
  • 3
  • 2
8 Comments
 
LVL 15

Expert Comment

by:Tomarse111
ID: 38810923
If its a windows box with IIS, you can create a virtual directory to where the external CSS files live. Then just reference them from there in the normal way.

http://www.iis.net/configreference/system.applicationhost/sites/site/application/virtualdirectory

Tom
0
 

Author Comment

by:Envisoin
ID: 38810954
Unfortunately I do not have access to the admin can create a virtual directory. Is there any way to do that programmatically using ColdFusion? I know you can do with images, but is impossible to include a CSS file from outside the web root and having work?
0
 
LVL 36

Accepted Solution

by:
SidFishes earned 500 total points
ID: 38811005
YOu can use cffile and then just write the variable within a style tag.

<cfoutput>
	<cffile action="read" file="c:\temp\test.css" variable="css">
<style>
#css#
</style>
<div>This is unstyled/</div>
<div id="test">this is styled</div></cfoutput>

Open in new window

0
 
LVL 15

Expert Comment

by:Tomarse111
ID: 38811008
You may be able to do it through the CF admin in Mappings but im pretty certain they are only accesible through certain CF tags .. like cfinclude. I dont think a <link> would work on it, so:

<link type="text/css" media="screen" rel="stylesheet" href="/folderdoutside/test.css" />

Would not work.

Why would you not put the CSS in your webroot? You could host it on another URL and reference that?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 36

Expert Comment

by:SidFishes
ID: 38811020
(I've shown you how to do what you want but I'd have to agree with Tomarse, why not put it in the webroot....?)
0
 

Author Comment

by:Envisoin
ID: 38811074
The reason I don't want to put in in the web root is because of an ex-friend of mine who was directly stealing my work. For the last 10 years I've been telling him to get on the CSS bandwagon and he has fought me over making the transition. He still doesn't all of these websites with in-line CSS. He recently was asked to make changes to one of his websites that had over 3200 pages of in-line CSS code and he asked me for help. He said he would pay me $500 out of the $2500 he was getting paid to redesign the site. He never paid me and every time I publish a new website he's been stealing my CSS code. Normally I would not care, but he is direct competition for me and my web design business and after what he did I will not help him!
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 38811104
well, unfortunately, you won't be able to prevent them from stealing css - it will -always- be visible, just as js has to be. If it's not, the browser can't use it. This is by design.

 Any tool like firebug will be able to inspect every css file.

Putting a copyright notice in your css files and then threatening with legal action is about all you can do
0
 

Author Closing Comment

by:Envisoin
ID: 38811128
Thank you for the rapid response to this question!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now