?
Solved

Including CSS files from outside the wwwroot in Coldfusion

Posted on 2013-01-23
8
Medium Priority
?
476 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 2000 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
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
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
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
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 …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

807 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