我想在产品页面上显示产品描述。 是否可以更改product.tpl来显示它?是否需要开发模块或更改核心类?
要在产品页面上显示制造商描述,最好的方法是创建对 ProductController 的覆盖,例如:
class ProductController extends ProductControllerCore
{
public function initContent(){
$manufacturer_description = "";
if($this->product->id_manufacturer > 0)
{
$manufacturer = new Manufacturer($this->product->id_manufacturer, $this->context->language->id);
$manufacturer_description = $manufacturer->description;
}
$this->context->smarty->assign('manufacturer_description', $manufacturer_description);
parent::initContent();
}
}
然后在主题的product.tpl 中将 {$manufacturer_description} 放置在您想要显示的位置。
不要忘记清除缓存,并在这些更改生效后删除文件cache/class_index.php。
对我来说,可以将其放在模板product-details.tpl上,覆盖原来的:
{$product_manufacturer->描述 nofilter}
需要“nofilter”标签来避免 html 显示在浏览器上
这是1.7版本的