1

我的英语不好所以请原谅我。

我想要这样的目录名称

Productname <span> product count </span> 

这里是product.tpl的代码

 <ul class="box-category">
  <?php foreach ($categories as $category) { ?>
  <li>
    <?php if ($category['category_id'] == $category_id) { ?>
    <a href="<?php echo $category['href']; ?>" class="active"><?php echo $category['name']; ?></a>
    <?php } else { ?>
    <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
    <?php } ?>
    <?php if ($category['children']) { ?>
    <ul>
      <?php foreach ($category['children'] as $child) { ?>
      <li>
        <?php if ($child['category_id'] == $child_id) { ?>
        <a href="<?php echo $child['href']; ?>" class="active"> - <?php echo $child['name']; ?></a>
        <?php } else { ?>
        <a href="<?php echo $child['href']; ?>"> - <?php echo $child['name']; ?></a>
        <?php } ?>
      </li>
      <?php } ?>
    </ul>
    <?php } ?>
  </li>
  <?php } ?>
</ul>

我认为它在 module/product.php 中的某个位置

    $children_data[] = array(
                'category_id' => $child['category_id'],
                'name'        => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
                'href'        => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) 
            );      
        }

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

但我不知道如何插入它,请帮助我!请!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

4

1 回答 1

0

您的数组应如下所示:

$children_data[] = array(
    'category_id' => $child['category_id'],
    'name'        => $child['name'] . ($this->config->get('config_product_count') ? ' <span>' . $product_total . '</span>' : ''),
    'href'        => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) 
);

$this->data['categories'][] = array(
    'category_id' => $category['category_id'],
    'name'        => $category['name'] . ($this->config->get('config_product_count') ? ' <span>' . $total . '</span>' : ''),
    'children'    => $children_data,
    'href'        => $this->url->link('product/category', 'path=' . $category['category_id'])
);  
于 2013-08-14T14:00:36.540 回答