我想在我们的 CS-Cart 商店的产品页面上向我们的用户展示国家代码。
我试过{$user_data.b_country}
什么不起作用。
Smarty 调试控制台也没有显示此信息,所以我想我必须先将此变量分配给view.tpl
文件。
我怎么解决这个问题?
在调用 tpl 上的变量之前,您需要分配给数组变量 $user_data b_country 是配置文件的一部分,客户可以拥有多个配置文件
下面的脚本将从主要配置文件中获取 b_country
1.添加文件
app/addons/my_changes/init.php
有内容
<?php
if (!defined('BOOTSTRAP')) { die('Access denied'); }
fn_register_hooks(
'sucess_user_login'
);
2.添加文件
app/addons/my_changes/func.php
有内容
<?php
if (!defined('BOOTSTRAP')) { die('Access denied'); }
function fn_my_changes_sucess_user_login(&$udata, $auth){
if(!isset($auth['b_country']) && $auth['user_id']>0){
$auth['b_country'] = db_get_field('SELECT b_country FROM `?:user_profiles` WHERE user_id = ?i AND profile_type = ?s', $auth['user_id'], 'P');
}
}
3.现在可以在tpl中使用了
{$auth.b_country}
我希望这会有所帮助
您可能应该尝试:
{$cart.user_data.b_country}