| Subject: | Re: (beginner) Coldfusion: variable to change language |
|---|---|
| From: | Ian Skinner <iskinner@xxxxxxxxxxx> |
| Date: | Thu, 31 Jul 2008 07:57:34 -0700 |
| Newsgroups: | macromedia.coldfusion.cfml_general_discussion |
<cfparam name="url.language" default="eng"><!--- Defines a default for the url language variable if one does not exist. ---> <cfset variables.lang = url.language><!--- Transfers the value of the url scope language variable to the local variables scope variable. ---> <!--- NOTE: This is rather redundant, since the URL scope and the Variables Scope will have the same life in this scenario. Thus url.language could be used anywhere variables.language is used. This would make more sense if the value was stored in a persistent scope such as session. --->
<cfif isdefined("lang") and lang eq "eng">
header html here
</cfif>
<cfif isdefined("lang") and lang eq "swe">
header html here (in swedish)
</cfif>
<!--- I would write this has a case or at least an if-elseif so to cut
down unnecessary processing. --->
<cfswitch expression="#variables.lang#">
<cfcase value="eng">
header html here
</cfcase>
<cfcase value="swe">
header html here (in swedish)
</cfcase>
</cfswitch>
OR
<cfif lang eq "eng">
header html here
<cfelseif lang eq "swe">
header html here (in swedish)
</cfif>
ALSO note with the <cfparam...> tag to provide a default the isDefined()
or prefered structKeyExists() function is unnecessary.
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: (beginner) Coldfusion: variable to change language, Jerrzzzz |
|---|---|
| Next by Date: | Re: Performance Monitor Will Not Work, ksmith |
| Previous by Thread: | Re: (beginner) Coldfusion: variable to change language, Jerrzzzz |
| Next by Thread: | Re: (beginner) Coldfusion: variable to change language, Magikaru |
| Indexes: | [Date] [Thread] [Top] [All Lists] |