我正在使用Prestashop 1.6并尝试将变量附加到已经实例化的smarty数组。我创建了一个* .tpl文件,并为smarty数组分配了一些变量,例如:
public function hookExtraCarrier($params)
{
//previous code is deleted.
$this->context->smarty->assign(array(
'wineo_free_shipping_id' => Configuration::get('WINEO_FREE_CARRIER_ID'),
'this_path' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/',
));
return $this->display(__FILE__, 'wineocarrier.tpl');
}
我有另一种方法,我想在数组中添加更多变量。我尝试过这样的事情:
public function addCarrierNameList()
{
//previous code is deleted.
if (isset($carrierNameNorm)) {
$this->context->smarty->assign(array(
'wineo_shipping_type' => $carrierNameNorm['name']
));
}
// echo '<pre>', print_r($carrierNameNorm['name']),'</pre>';
// return $this->display(__FILE__, 'wineocarrier.tpl');
}
}
我无法获得&#39; wineo_shipping_type&#39;模板文件中的变量。
最好的方法是什么?
感谢!!!