flamingsquirrel

Archive for the ‘coldfusion’ Category

Using cfswith to specify different circuits

Monday, February 25th, 2008

I use the following code to use specific imagery or code on different sections of the website.

<cfswitch expression=”#UCase(myFusebox.OriginalCircuit)#”>
<cfcase value=”CIRCUIT NAME 1″>
</cfcase>
<cfcase value=”CIRCUIT NAME 2″>
</cfcase>
<cfdefaultcase>If neither circuit 1 or 2</cfdefaultcase>
</cfswitch>

If you need to target more than one circuit then separate them with a comma.

<cfcase value=”CIRCUIT NAME 1, CIRCUIT NAME 2, CIRCUIT NAME 3″>

Another method that works really well is:

<cfif ListFindNoCase(“home”, myFusebox.originalcircuit) neq 0>
Display this text on the home page circuit
<cfelse>
otherwise display this on every other page
</cfif>

Rotate elements on your page using cfswitch

Thursday, February 21st, 2008

I have been using cfswitch to rotate banner images and quotes.

<cfswitch expression="#RandRange(1, 4)#">
 <cfcase value="1">Option A</cfcase>
 <cfcase value="2">Option B</cfcase>
 <cfcase value="3">Option C</cfcase>
 <cfdefaultcase>Option D</cfdefaultcase>
</cfswitch>

cfloop Example

Thursday, February 14th, 2008

Use cfloop to change a class on every odd row.

<cfloop from=”1″ to=”something” index=”idx”>
<li <cfif idx mod 2>class=”odd”</cfif>>

Subscribe to this site