0

http://imgur.com/a/Znuvv

每个类别和子类别都有一个图像。将拇指放在下拉菜单中时,子猫会加载其父母的拇指。目录/控制器/common/header.php 文件:

if ($category['top']) {
            // Level 2
            $children_data = array();
            $children = $this->model_catalog_category->getCategories($category['category_id']);
            foreach ($children as $child) {
                $filter_data = array(
                    'filter_category_id'  => $child['category_id'],
                    'filter_sub_category' => true
                );          
                $children_data[] = array(                        
                    'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
                    'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
                );
            }
            // Level 1
            $this->load->model('tool/image');
            $image = empty($category['image']) ? 'no_image.png' : $category['image'];
            $thumb = $this->model_tool_image->resize($image, 100, 100);

            $data['categories'][] = array(
            'name'     => $category['name'],
            'children' => $children_data,
            'column'   => $category['column'] ? $category['column'] : 1,
            'thumb'    => $thumb,
            'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
        );
        }

这是我的目录/视图/主题/default/template/common/header.tpl 文件:

<ul class="list-unstyled">
            <?php foreach ($children as $child) { ?>
            <li><a href="<?php echo $child['href']; ?>"><img src="<?php echo $category['thumb']?>" alt="<?php echo $child['name']; ?>"/>
            <a src="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>
            <?php } ?>
          </ul>

知道这可能是什么原因吗?

4

1 回答 1

0

$category['thumb']

而不是

$child['thumb']

所以,是的,就是这样。

于 2017-02-19T15:40:49.160 回答