2015-11-21 95 views
0

在每個產品頁面上我目前已顯示產品子類別,但只有一個深度級別。所以,如果在類別中我有Brother > MFC > B4564 > TN450 ....並且我在TN450的產品頁面上,在它下面它將只顯示BN4564。我需要它也顯示mfcbrother部分。我不知道如何做到這一點..任何想法?這是我目前的代碼。Opencart顯示子類別

.TPL文件

<!-- Display product categories --> 

<?php foreach ($catprod as $catp) 
{ 

    ?><a href="<?php echo $catp['href']; ?>"><?php echo $catp['name']; ?> </a><?php 

}` 

控制器PHP文件

$data['catprod'] = array(); 
$product_category = $this->model_catalog_product->getCategories($this->request->get['product_id']); 

foreach ($product_category as $prodcat) 
{ 
    $category_info = $this->model_catalog_category->getCategory($prodcat['category_id']); 
    if ($category_info) 
    { 
     $data['catprod'][] = array('name' => $category_info['description'],'href' => $this->url->link('product/category', 'path=' . $category_info['category_id'])); 
    } 
}` 

回答

0

其中Opencart的版本? 這應該換版工作1: 開放catalog/view/theme/default/template/module/category.tpl 刪除其內容並插入:

 <div class="box" id="categories-menu"> 
     <div class="box-heading"><?php echo $heading_title; ?></div> 
     <div class="box-content"> 
<ul class="box-category" id="box-category"> 
    <?php foreach ($categories as $category) { ?> 
    <li> 
    <?php if ($category['category_id'] == $category_id) { ?> 
    <a href="<?php echo $category['href']; ?>" class="active list-group-item" ><?php echo $category['name']; ?></a> 
    <?php } else { ?> 
    <a href="<?php echo $category['href']; ?>" class="list-group-item" style = "font-weight: normal;"><?php echo $category['name']; ?></a> 
    <?php } ?> 
    <?php if ($category['children']) { ?> 
    <ul class="submenu"> 
     <?php foreach ($category['children'] as $child) { ?> 
     <li> 
     <?php if ($child['category_id'] == $child_id) { ?> 
     <a href="<?php echo $child['href']; ?> class="list-group-item"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - <?php echo $child['name']; ?></a> 
     <?php } else { ?> 
     <a href="<?php echo $child['href']; ?>" class="list-group-item"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - <?php echo $child['name']; ?></a> 
     <?php } ?> 
     </li> 
     <?php } ?> 
    </ul> 
    <?php } ?> 
    </li> 
    <?php } ?> 
</ul> 
</div> 

+0

我使用2.0.x版謝謝你不好意思看看它! –