Including CSS Stylesheet within an Application.cfc

Managing CSS Stylesheets in Application.cfc

Page 1 of 1

1 Replies - 3532 Views - Last Post: 12 February 2010 - 07:50 AM Rate Topic: ***** 2 Votes

#1 dreamstarter  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-October 09

Including CSS Stylesheet within an Application.cfc

Posted 11 February 2010 - 12:46 PM

Upgrading an old coldfusion web app. Currently the application declares the stylesheet in the application.cfm.

<!--- Define CSS --->    
<style type="text/css" media="screen">
    @import url("CSS/style.css");
</style>



I have tried scripting out the code in the onRequest and onApplicationstart functions within the new application.cfc without success.

<cffunction name="onApplicationstart" returnType="boolean" output="false"> 
<cfset app_name="appName">
<!--- Define Application Datasource --->
<cfif NOT IsDefined("application.datasource")>
     <cfset application.datasource="appDatabase">
</cfif> 
 
<style type="text/css" media="screen">
    @import url("/CSS/style.css");
</style>

<cfreturn true> 

</cffunction>



Is This A Good Question/Topic? 0
  • +

Replies To: Including CSS Stylesheet within an Application.cfc

#2 xheartonfire43x  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 454
  • Joined: 22-December 08

Re: Including CSS Stylesheet within an Application.cfc

Posted 12 February 2010 - 07:50 AM

What you could do is in your onRequestEnd method add:
<cfhtmhead text='<style type="text/css" media="screen">
    @import url("/CSS/style.css");
</style>
' />



That will work as long as you have HTML <head></head> tags on all the pages that need the stylesheet. The tag adds the text in between <head></head> tags, but I am pretty sure it needs to be after the page is processed by ColdFusion. Truthfully I have not tested under onRequestStart.
The tag also becomes extremely useful when using <cfinclude> pages.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1