在,前$this->data['products'][] = array(
地址:
$categories = $this->model_catalog_product->getCategories($result['product_id']);
if($categories){
$categories_info = $this->model_catalog_category->getCategory($categories[0]['category_id']);
$category_title = $categories_info['name'];
}else{
$category_title = '';
}
更新$this->data['products'][]
排列如下:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'category_title' => $category_title,
'thumb' => $image,
'name' => $result['name'],
'price' => $price,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
現在latest.tpl
,你會得到的類別標題$product['category_title']
。
附加信息: - 應在控制器內調用模型功能。控制器中定義的變量$this->data['variable_name']
可以在模板文件中作爲$variable_name
訪問。
有一個nayay!
感謝Sankar V ........... – user3190238