Dec
14
ColdFusion
· By Michael Ferguson
Did you know that you can add HTML items to the title of a CFLAYOUTAREA?οΎ This works out really well if you would like to include an icon or special button that is completely independent of the content being displaying inside the layout.
<cfset IconFolder="<img src="&Chr(34)&"/Info.png"&Chr(34)&" width=20 height=20 />">
<cflayout type="border" name="PanelParent" align="left" fittowindow="yes">
<cflayoutarea position="left" title="#IconFolder# INSTRUCTIONS" size="250">
Stuff
</cflayoutarea>
</cflayout>
The code above will place an icon in the title just before the word "instructions". Hope you can find a good use for this one! Enjoy!
If you find this post useful please leave a comment and let me know how you used the information.
Nov
25
ColdFusion
· By Michael Ferguson
Here is a User Defined Function I created that will take a numeric file size value and convert it to abbreviated file size text. The function will append "bytes" if the number is less than 1000. It will strip of the last three numbers if the file size is between 1000 and 999999 and append " kb" to the number. Lastly, it will strip off the last six numbers if the file size is greater than or equal to 1000000 and append " mb" to the number. If you need it to also show gigabyte notation, the last conditional will need to be changed and fourth added to handle the larger file size.
<cffunction name="fnFileSize" access="public" returntype="string">
<cfargument name="FileSize" type="numeric" required="yes">
<cfscript>
ConvertSize=0;
if (FileSize LT 1000) {
ConvertSize=FileSize & " bytes";}
if (FileSize GTE 1000 AND FileSize LTE 999999) {
ConvertSize=Left(FileSize, Len(FileSize)-3) & " kb";}
if (FileSize GTE 1000000) {
ConvertSize=Left(FileSize, Len(FileSize)-6) & " mb";}
return ConvertSize;
</cfscript>
</cffunction>
If you find this post useful please leave a comment and let me know how you used the information.
Nov
25
ColdFusion
· By Michael Ferguson
If you think the built-in drop shadow for the CFWINDOW render is too weak, there is a way you can provide the illusion that the window is further away from the main content. To make the change for every CFWINDOW on the server you can edit the theme CSS in the CFIDE (ColdFusion 8) or the "ext-all.css" file (ColdFusion 9) also in the CFIDE folder, or to just change one page add the following style statement.
<style type="text/css">
.x-ie-shadow {
background: #000;
zoom: 1.01;}
</style>
Just like the CFGRID border style statement from the previous entry, this works because styles are the executed in the order presented. Last one loaded, wins.
If you find this post useful please leave a comment and let me know how you used the information.
Nov
25
ColdFusion
· By Michael Ferguson
I noticed that ColdFusion 9 has a two pixel border around the CFGRID render thanks to the ext-all cascading stylesheet. In case you want to know how to remove the border, you can either edit the "ext-all.css" file in your CFIDE folder (which will remove the border from every CFGRID) or just add the following style statement in your CFGRID page (which will only change the current page).
<style type="text/css">
.x-grid-panel .x-panel-body {
border: 0px;}
</style>
This works because styles are the executed in the order presented. Last one loaded, wins.
If you find this post useful please leave a comment and let me know how you used the information.
Nov
7
There are times when you do not want to use a query of queries. I try to avoid using them at all costs. They are slow and can use far too many system resources. As an alternative you can use Java indexOf, especially if you only want to determine if a value exists in a query. For example let's use the Northwind data source:
<cfquery name="GetCustomer" datasource="Northwind">
SELECT OrderID, CustomerID, EmployeeID
FROM Orders
</cfquery>
This quarry will pull over 800 results. To avoid re-querying the database to determine if a returned value exists and to avoid a query of queries, test for the index of that value in the query.
<cfset SearchCustomerID="RATTC">
<cfset TestIndex=GetOrder["CustomerID"].IndexOf(JavaCast("string", SearchCustomerID))>
<cfif TestIndex GTE 0>
<cfoutput>#SearchCustomerID# = #TestIndex#</cfoutput><br />
</cfif>
Remember though this is java and the index starts at zero unlike cold fusion which starts at one. This means that the index returned is 14 but the actual row number from the result is 15. If the index returned is a negative number it does not exist in the query. Therefore zero or any positive number means the value exists.
If you find this post useful please leave a comment and let me know how you used the information.