Hi all,
 
A client needed to have content routed in certain folders based on US states.  Now, I know a bunch of you are not from the US, but I thought I would share this code with you all, perhaps someone can reuse it in some way.  It is pretty simple and made very easy by FU.  After my vacation next week I will have some more code I would like to share.  Thus far an ATM/Bank Locator and a User Form review utility.
 
Anyhow, this file is essentially called in as an include into the root of a folder and then pushes the user to section, based on state.
 
Here is the "Content Router".  
 
 
@@@@@@@@@@@@@@@@@@@@@@@@BEGIN@@@@@@@@@@@@@@@@@@@@@@@@
 
<!---
Four Eyes Productions 06-18-03
::set cookie for user
::route user to content based on state from DB
--->
 

<cfparam name="cookie.myState" default="">
<cfparam name="form.myState" default="">
 
 <!--- get states --->
<cfquery name="qStates" datasource="#application.dsn#">
  SELECT *
  FROM cmStates
  WHERE status = 'approved'
  ORDER BY title
 </cfquery>
 
 
<cfoutput>
<!---
uncomment for quick cookie delete
<cfcookie name="myState" value="#form.myState#" expires="NOW">
--->
 

<cfif isdefined("cookie.myState") AND len(cookie.myState)<!---test for cookie (begin)--->>
 
<cflocation url="" addtoken="No">
 
<cfelse<!---test for cookie (if no cookie)--->>
 
<cfif isdefined("form.process")<!--- process to set cookie (begin) --->>
 
<cfcookie name="myState" value="#form.myState#" expires="NEVER">
 

<cflocation url="" addtoken="No">
 
<cfelse<!--- process to set cookie (show the form) --->>
 

Please select your state from the pull down below and click the "go" button.  If your computer's security settings allow cookies, your state will be set to a cookie and you will not be presented with this option again, you will be directed to contenct in this section appropriate to your state.<br />
<br /><br />
If your computer's security settings do not allow cookies, then this option will be presented to you at various points in the web site to help direct you to the appropriate content for your state.<br>
 
<form action="" method="post" name="RouteState" id="RouteState">
<select name="myState">
<option value="">Please Select</option>
<cfloop query="qStates">
<option value="#LCase(qStates.title)#">#qStates.title#</option>
</cfloop>
</select>
<input type="submit" name="process" value="go">
</form>
 
 
 
</cfif <!--- process to set cookie (end) --->>
 
</cfif <!---test for cookie (end)--->>
 
</cfoutput> 
 
@@@@@@@@@@@@@@@@@@@@@@@@END@@@@@@@@@@@@@@@@@@@@@@@@
 
 
Not complicated, just some raw code.  It gets the job done.

--
Regards,
Michael
---
You are currently subscribed to farcry-dev as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to