macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: (beginner) Coldfusion: variable to change language

Subject: Re: (beginner) Coldfusion: variable to change language
From: Ian Skinner <iskinner@xxxxxxxxxxx>
Date: Thu, 31 Jul 2008 07:17:29 -0700
Newsgroups: macromedia.coldfusion.cfml_general_discussion


Jerrzzzz wrote:
Woah, fast answers.

Thing is, I think that this page may not be constructed in the best way (I'm certainly not gonna try and redo it, as I only have a few more weeks on this job and know next to zero about CF)

<cfset language = "new language"> This was how I wrote it in application.cfm. I then tried to change that parameter with a link <a href="application.cfm?language=eng">English</a> This, however, doesnt work. I guess that is totally wrong.

Not totally wrong, but missing an understanding of the various variable scopes involved.

<cfset language = "new language"> 'language' is a local variable to this request and will only live until the end of the request. This would be fully qualified if it was written as <cfset variables.language = "new langage">

<a href="application.cfm?language=eng">English</a> This 'language' variable will be in the URL scope. It would be fully qualified with "url.language">

To get these working together you will need what I wrote in my original replay. <cfset language = url.language> Or better yet. <cfset variables.language = url.language>

The next part will probably be to persist this local language value from request to request. That is usually done with a session variable so the above line would become something like this. <cfset session.language = url.language>. But there is a bit more to session variable if the application is not already configured to use them.

<Prev in Thread] Current Thread [Next in Thread>