在特定页面中显示所有类别和子类别,如站点地图
Show all Category & Sub- Category in a particular page like as sitemap
我是 opencart 新手。我只想在
中显示所有类别和子类别
像网站地图一样的特定页面,我的老板很喜欢。
查看此代码。只需将其粘贴到您想要的控制器中即可。
$data['categories'] = array();
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
echo $category['name'] . '<br/>';
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
echo ' --- ' . $child['name'] . '<br/>';
}
}
我是 opencart 新手。我只想在
中显示所有类别和子类别像网站地图一样的特定页面,我的老板很喜欢。
查看此代码。只需将其粘贴到您想要的控制器中即可。
$data['categories'] = array();
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
echo $category['name'] . '<br/>';
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
echo ' --- ' . $child['name'] . '<br/>';
}
}