Saturday, June 11, 2005

Coldfusion - Proper Case For Names

Format a string so that it appears like a properly formatted name. For example: "daVId" becomes "David" or "dr. bones" becomes "Dr. Bones". The code uses a single line of semi-complex Regex through the REReplace() function. First it changes the input string to lower case, then it searches for all instances of: a) a character at the beginning of the string, or b) a character preceeded by a blank (tab or space) ..and replaces the match with it's uppercase equivalent..

Associated Code :
<cfparam name="Variables.fullName" default="dr. bones">

<cfset Variables.formattedName = REReplace(LCase(Variables.fullName), "(^[[:alpha:]]|[[:blank:]][[:alpha:]])", "\U\1\E", "ALL")>


Friday, June 10, 2005

Keep Robots Out Of Your Pages

If you would like to keep robots out of your pages use the following META tag in the top of your pages.

<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">

In a file on your servers named "robots.txt" place this text:
User-agent: *
Disallow: /

Thursday, June 09, 2005

How Can I Change CFLOOP To Count ON Ordered Alpha Fields

I need to do a loop not by the primary key field, but by an alpha field. But ordering the query as below still results in a order by the numerical ID field.

How can I change the cfloop to do a count on the ordered alpha fields?

<cfquery name="checksector" datasource="dbname">
FROM sectors
ORDER BY sector

<cfloop index = "LoopCount" from = "1" to = "#checksector.recordcount#">

Wednesday, June 08, 2005

Coldfusion Write to File

Using Coldfusion, how can I write to a file that is on the server from my browser.

This will get you started.

<cfset currpath=getdirectoryfrompath(getcurrenttemplatepath())>
<cffile action="APPEND" file="#CurrPath#Foo.txt" output="My Foo can beat up your foo." addnewline="Yes">

Tuesday, June 07, 2005

Need Help With A Cascading Background (Part 2)

Though yesterdays tip gave great instructions on how to do this in Dreamweaver, there is an alternative method. Just use the following in your stylesheet (either embedded or external):

body {
background-color:#fff; /*background color for the page*/

this can also be shortened to:

body {#fff url("path/to/your/image.jpg")no-repeat;}

Dreamweavers handling of CSS is sometimes a little difficult, however, CSS really isn't that complex and you'll find that learning the basics will save you lots of clicking through endless Dreamweaver palettes.

Monday, June 06, 2005

Need Help With A Cascading Background (Part 1)

I would like to have a cascading background and I'm using Dreamweaver MX, how can I achieve this?
<li>Remove the background image you currently have.
<li>Go to the CSS Styles Panel (it should be in the top right corner of the screen, in the Design Panel Group.
<li>Click on the Add New Style button in the bottom right corner of the panel. It's the button with the little blue plus sign.
<li>From the center of the dialog box, choose the middle radio button that says "Tag", and then go to the top of the dialog box and select Body from the list of HTML tags. At the bottom, you'll need to decide whether you want this available to just this one page or to other pages by creating an external stylesheet. Either way, click Okay.
<li>In the next dialog box, click on Background over on the left. Browse to the image you want, and select "no-repeat" from the drop-down labelled Repeat.
<li>Click okay, and you're all set.

Sunday, June 05, 2005

Coldfusion Reference Query Row

I need to be able to reference a row in my queries output, how can I do that?

<cfset #NumberOfRows# = #A_Number#>
<cfquery name="myquery" datasource="mydbase">
Select field1, field2 From mytable
<cfoutput> #myquery.field1[NumberOfRows]# </cfoutput>