私は走っていColdfusion8/MySQL 5.0.88
ます。
データベースに 2 つのテーブルがあります。
modules
textblocks
私のサイトは複数の言語を実行しているため、ユーザーが選択した言語に応じてデータベースからテキストブロックをロードするために、すべてのページの先頭でこれを行っています。
<cfquery datasource="#Session.datasource#" name="texte">
SELECT *
FROM textblocks
WHERE lang = <cfqueryparam value = "#Session.lang#" cfsqltype="cf_sql_varchar" maxlength="2">
</cfquery>
<cfoutput query="texte">
<cfset "#trim(label)#" = "#trim(content)#">
</cfoutput>
label
テキストブロックが必要な場合は、次のように単純に使用できます。
<cfoutput>#tx_hello_world#</cfoutput>
私の問題は、モジュールのリストを含む 2 番目のテーブルにあります。
各モジュールには独自の説明があります (ヘッダー、サブヘッダー、情報、箇条書き 1 ~ 5)。すべてのモジュール (25) をループlabels
する必要があるため、単一のループを実行しlabels
てデータベースから出力することを期待して、データベースに保存しました。残念ながらlabel123
リターンを出力しています
#label123#
vs私が望んでいる
"text from table textblocks stored at label123"
質問:
「動的変数」を MySQL に保存し、これらを出力する際に、それらの基になる値を取得することは可能ですか? そうでない場合、「これがモジュールAの場合、テキストtx_module_a_titleを取得し、そうでない場合は...」と言わずに、単一のループで25個のモジュールを出力するより良いアプローチは何ですか?
ありがとう!
編集:
だから私はこれをすべてのループで実行しなければならないことを避けたいと思っています:
<cfif mods.module_name EQ "agents">
<cfset variables.module_header = tx_module_b2b_agents_title>
<cfset variables.module_subheader = tx_module_b2b_agents>
<cfset variables.module_info = tx_module_b2b_agents_info>
<cfset variables.module_bull_1 = tx_module_b2b_agn_accounts>
<cfset variables.module_bull_2 = tx_module_b2b_agn_price_clients>
<cfset variables.module_bull_3 = tx_module_b2b_agn_client_mgt>
<cfset variables.module_bull_4 = tx_module_b2b_agn_create_retailer>
<cfset variables.module_bull_5 = tx_module_b2b_exp_grace>
<cfset variables.module_usage_tx = tx_vertreter/tx_gen_month>
<cfelseif mods.module_name EQ "preorder">
<cfset variables.module_header = tx_module_b2b_preorder_title>
<cfset variables.module_subheader = tx_module_b2b_preorder>
<cfset variables.module_info = tx_module_b2b_preord_info>
<cfset variables.module_bull_1 = tx_module_b2b_pre_split_type>
<cfset variables.module_bull_2 = tx_module_b2b_pre_qty_y_n>
<cfset variables.module_bull_3 = tx_module_b2b_pre_deliverydate>
<cfset variables.module_bull_4 = tx_module_b2b_exp_grace>
<cfset variables.module_bull_5 = "">
<cfset variables.module_usage_tx = tx_gen_month >
<cfelseif mods.module_name EQ "export">
<cfset variables.module_header = tx_module_b2b_export_title>
<cfset variables.module_subheader = tx_module_b2b_export>
<cfset variables.module_info = tx_module_b2b_export_info>
<cfset variables.module_bull_1 = tx_module_b2b_exp_pricelists>
<cfset variables.module_bull_2 = tx_module_b2b_exp_currencies>
<cfset variables.module_bull_3 = tx_module_b2b_exp_customerlist>
<cfset variables.module_bull_4 = tx_module_b2b_exp_regional_assortme>
<cfset variables.module_bull_5 = tx_module_b2b_exp_grace>
<cfset variables.module_usage_tx = tx_gen_month>
... 22 else-ifs to go
</cfif>
tx_
データベースモジュールレコードの値の後ろにテキストブロックを保存できれば、そこから値を取得できます。