在每个产品页面上,我目前已经显示了产品子类别,但只有一个级别。因此,如果在类别中我有Brother > MFC > B4564 > TN450
....而且我在TN450的产品页面上,则在其下方只会显示BN4564
。我需要它还会显示mfc
和brother
部分。我不知道怎么做...有什么想法吗?这是我目前的代码。
.TPL文件
<!-- Display product categories -->
<?php foreach ($catprod as $catp)
{
?><a href="<?php echo $catp['href']; ?>"><?php echo $catp['name']; ?> </a><?php
}`
controller .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 :(得分: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"> - <?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>" class="list-group-item"> - <?php echo $child['name']; ?></a>
<?php } ?>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
</ul>
</div>