0

您好,我想用 smarty 在 prestashop 的模板文件中分配一个变量。我怎样才能做到这一点?

到目前为止,我有以下代码:

{$db = DB::getInstance()}
{$id_lang = Context::getContext()->language->id}
{$sql = 'SELECT value FROM ps_feature_value_lang WHERE id_feature_value = 29 AND id_lang = $id_lang'} <- this is not working
4

1 回答 1

1

它不起作用,因为变量在引号内。您需要将字符串与变量连接起来。未经测试,但应该是这样的:

{$sql = 'SELECT value FROM ps_feature_value_lang WHERE id_feature_value = 29 AND id_lang = '|cat:$id_lang}
于 2013-01-17T11:08:21.387 回答