Created
September 2, 2013 20:03
-
-
Save steinbring/6416774 to your computer and use it in GitHub Desktop.
This is an experiment in the dynamic population of a variable scope, based upon the content within a table. It could be really useful for the localization of content.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfsilent> | |
<cfif isDefined("url.language")> | |
<cfquery name="VocabQuery" datasource="erp"> | |
select vcName as name, | |
vcValue as value, | |
vcLanguage as language | |
from tblVocab | |
where vcLanguage = <cfqueryparam cfsqltype="cf_sql_varchar" value="#url.language#"> | |
</cfquery> | |
<cfset variables.vocabulary = StructNew()> | |
<cfloop from="1" to="#VocabQuery.recordcount#" index="i"> | |
<cfset "variables.vocabulary.#VocabQuery.name[i]#" = trim(VocabQuery.value[i])> | |
</cfloop> | |
</cfif> | |
</cfsilent> | |
<form method="get"> | |
<select name="language"> | |
<option value="en">English</option> | |
<option value="sp">Spanish</option> | |
<option value="la">Latin</option> | |
</select> | |
<input type="submit" name="submit" value="Load"> | |
</form> | |
<cfif isDefined("variables.vocabulary")> | |
<cfdump var="#variables.vocabulary#"> | |
</cfif> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment