如何将<span> </span>添加到目录计数(Opencart目录模块)

时间:2013-08-01 12:55:24

标签: opencart catalog

我的英语不好,请原谅我。

我想要我的目录名称

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'])
        );  
    }

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

1 个答案:

答案 0 :(得分: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'])
);