1

我在 opencart 管理面板中添加了 4 个类别作为 4 个级别,

Home
Home -> Furniture
Home -> Furniture -> Wooden (Getting menus up to this level)
Home -> Furniture -> wooden -> Lightweight (Need to display this level)

最初我在菜单中显示第三级类别时遇到问题。我使用这篇文章启用了第三级菜单

像这样如何启用第 4 级类别。

4

4 回答 4

2

标头控制器

$data['categories'] = array();

    $categories = $this->model_catalog_category->getCategories(0);

    foreach ($categories as $category) {

        if ($category['top']) {
            // Level 2
            $children_data = array();

            $children = $this->model_catalog_category->getCategories($category['category_id']);

            foreach ($children as $child) {

                // Level 3 sultan
                $children_data_3 = array();

                $children_3 = $this->model_catalog_category->getCategories($child['category_id']);

                foreach ($children_3 as $child_3) {

                    $filter_data_3 = array(
                        'filter_category_id'  => $child_3['category_id'],
                        'filter_sub_category' => true
                    );

                    $children_data_3[] = array(
                        'name'  => $child_3['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data_3) . ')' : ''),
                        'href'  => $this->url->link('product/category', 'path=' . $child['category_id'] . '_' . $child_3['category_id'])
                    );
                }
                //end of level 3


                $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']),
                    'grand_childs' => $children_data_3

                );
            }

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

    }

tpl代码

  <ul class="nav navbar-nav">


    <?php foreach ($categories as $category) { ?>
    <?php if ($category['children']) { ?>


    <li class="dropdown">
     <a href="<?php echo $category['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $category['name']; ?></a>

      <div class="dropdown-menu">
        <div class="dropdown-inner">
          <?php foreach (array_chunk($category['children'], ceil(count($category['children']) / $category['column'])) as $children) { ?>
          <ul class="nav">
            <?php foreach ($children as $child) { ?>

              <li class="dropdown-submenu" >
              <a href="<?php echo $child['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $child['name']; ?></a>

               <?php if($child['grand_childs']){
                echo '<ul class="dropdown-menu sub-menu">';
              foreach($child['grand_childs'] as $grand_child){ ?>
                        <li>
                          <a href="<?php echo $grand_child['href']; ?>" ><?php echo $grand_child['name']; ?></a>
                        </li>
            <?php }
                echo '</ul>';
            }
            ?>
            </li>


            <?php } ?>

          </ul>
          <?php } ?>

        </div>
        <a href="<?php echo $category['href']; ?>" class="see-all"><?php echo $text_all; ?> <?php echo $category['name']; ?></a> </div>
    </li>
    <?php } else { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
    <?php } ?>
    <?php } ?>

  </ul>
于 2015-11-02T10:42:31.840 回答
0

用于在主菜单中显示子类别。请进行以下更改。

编辑 header.php 控制器文件

 $sec_children_data = array();
                $sec_children = $this->model_catalog_category->getCategories($child['category_id']);

                foreach ($sec_children as $sec_child) {
                    $sec_children_data[] = array(
                        'name'  => $sec_child['name'] . ($this->config->get('config_product_count') ? '' : ''),
                        'href'  => $this->url->link('product/category', 'path=' . $child['category_id'] . '_' . $sec_child['category_id'])
                    );

                }

编辑 header.tpl

?php if (isset($category['children'][$i]['level3'])) {  
          $level3menus = $category['children'][$i]['level3'];
          ?>
          <ul class="level3">
          <?php
                foreach( $level3menus as $level3menu) {
          ?>
                <li><a href="<?php echo $level3menu['href']; ?>" class=""><?php echo $level3menu['name'];?></a></li>
          <?php } ?>

请参考我的教程一步一步的解释和演示。

于 2016-12-16T09:46:05.877 回答
0

首先从这里下载 vqmod然后解压它。现在 vqmod 文件夹保存在您的站点根目录中。然后去浏览器写你的站点 url 然后“/vqmod/install”然后按回车然后你会收到一条消息,你可以在你的站点中成功安装 vqmod。现在你在这里下载一个扩展表格并解压它。并在您的站点中保留提取文件,表明 folder exm:menu3rdlevel-opencart-2_2\vqmod\xml/Menu3rdLevel.xml 文件在您的站点中,例如:vqmod\xml/Menu3rdLevel.xml 它们是带有“menu3rdlevel”文件夹的其他文件。从扩展文件夹“javascript”到站点文件夹“javescript”,扩展文件夹“image”到站点文件夹“image”扩展文件夹“stylsheet”到站点文件夹“stylsheet”。

注意:仅传输 xml 文件和带有“menu3rdlevel”文件夹的其他文件。

于 2016-02-11T04:09:48.673 回答
-1

我自己做的,

将 header.tpl 文件更改为

<?php if (isset($_SERVER['HTTP_USER_AGENT']) && !strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6')) echo '<?xml version="1.0" encoding="UTF-8"?>'. "\n"; ?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title; ?></title>
<base href="<?php echo $base; ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<?php if ($description) { ?>
<meta name="description" content="<?php echo $description; ?>" />
<?php } ?>
<?php if ($keywords) { ?>
<meta name="keywords" content="<?php echo $keywords; ?>" />
<?php } ?>
<?php if ($icon) { ?>
<link href="<?php echo $icon; ?>" rel="icon" />
<?php } ?>
<?php foreach ($links as $link) { ?>
<link href="<?php echo $link['href']; ?>" rel="<?php echo $link['rel']; ?>" />
<?php } ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/fashioncart/stylesheet/stylesheet.css" />
<?php foreach ($styles as $style) { ?>
<link rel="<?php echo $style['rel']; ?>" type="text/css" href="<?php echo $style['href']; ?>" media="<?php echo $style['media']; ?>" />
<?php } ?>
<script type="text/javascript" src="catalog/view/javascript/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="catalog/view/javascript/jquery/ui/jquery-ui-1.8.16.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/ui/themes/ui-lightness/jquery-ui-1.8.16.custom.css" />
<script type="text/javascript" src="catalog/view/javascript/jquery/ui/external/jquery.cookie.js"></script>
<script type="text/javascript" src="catalog/view/javascript/jquery/colorbox/jquery.colorbox.js"></script>
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/colorbox/colorbox.css" media="screen" />
<script type="text/javascript" src="catalog/view/javascript/jquery/tabs.js"></script>
<script type="text/javascript" src="catalog/view/javascript/common.js"></script>
<script type="text/javascript" src="catalog/view/theme/fashioncart/javascript/fashioncart_custom.js"></script>
<script type="text/javascript" src="catalog/view/theme/fashioncart/javascript/cloud_zoom.js"></script>

<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600' rel='stylesheet' type='text/css'>

<?php foreach ($scripts as $script) { ?>
<script type="text/javascript" src="<?php echo $script; ?>"></script>
<?php } ?>
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/fashioncart/stylesheet/ie8.css" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/fashioncart/stylesheet/ie7.css" />
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/ie6.css" />
<script type="text/javascript" src="catalog/view/javascript/DD_belatedPNG_0.0.8a-min.js"></script>
<script type="text/javascript">
DD_belatedPNG.fix('#logo img');
</script>
<![endif]-->
<?php echo $google_analytics; ?>
</head>
<body>

<div id="container">

<div id="header">
  <?php if ($logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>

      <div id="welcome">
        <?php if (!$logged) { ?>
        <?php echo $text_welcome; ?>
        <?php } else { ?>
        <?php echo $text_logged; ?>
        <?php } ?>
      </div>

     <div class="sign_up_pd">
        <a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a> <a href="<?php echo $account; ?>"><?php echo $text_account; ?></a><a href="<?php echo $shopping_cart; ?>"><?php echo $text_shopping_cart; ?></a><a href="<?php echo $checkout; ?>"><?php echo $text_checkout; ?></a>
        <a href="<?php echo $publisher_sign; ?> " title="Publisher" > Publisher </a>
        <a href="<?php echo $developer_sign; ?> " title="Developer" > Developer </a>
     </div>
     <div class="clear_both"></div>

      <?php echo $cart; ?>


  <div id='header_btm'>
  <span class="span_lable">Search: </span>
    <select name="search_categories" id="search_categories" >
    <option value="0" >All Category</option>
      <?php foreach ($categories_search as $category) { ?>
            <?php if($category['category_id'] == $filter_category_id): ?>
            <option selected="selected" value="<?php echo $category['category_id'];?>" ><?php echo $category['name'];?></option>
            <?php else: ?>
            <option value="<?php echo $category['category_id'];?>" ><?php echo $category['name'];?></option>
            <?php endif; ?>

            <?php foreach ($category['children'] as $subcategory) { ?>
            <?php if($subcategory['category_id'] == $filter_category_id): ?>
            <option selected="selected" value="<?php echo $subcategory['category_id'];?>" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $subcategory['name'];?></option>
            <?php else: ?>
            <option value="<?php echo $subcategory['category_id'];?>" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $subcategory['name'];?></option>
            <?php endif; ?>
            <?php } ?>


     <?php } ?>
    </select>

    <div id="search">
        <div class="search_inside">
            <?php if ($filter_name) { ?>
            <input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
            <?php } else { ?>
            <input type="text" name="filter_name" value="<?php echo $text_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#444444';" />
            <?php } ?>

            <div class="button-search"></div>
        </div>
      </div>
    <?php echo $language; ?>
    <?php echo $currency; ?>
  </div>

</div>

<?php if ($categories) { ?>
<div id="menu">
  <ul>
    <li><a href="<?php echo $home; ?>"><span class='home_icon'></span></a>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>               
            <!-- Begin Part 1 of the extension Header menu add level 3 sub categories extension (line to be replaced: number 84 of the header.tpl file) -->      
            <li>
            <?php
            if(count($category['children'][$i]['children_level2'])>0){
            ?>
                  <a href="<?php echo $category['children'][$i]['href']; ?>"  onmouseover='JavaScript:openSubMenu("<?php echo $category['children'][$i]['id']; ?>")'><?php echo $category['children'][$i]['name']; ?></a>
            <?php

                  //echo "<img src='catalog/view/theme/default/image/arrow-right.png' style='right:10px;margin-top:3px;position:absolute;'/></a>";
                  //echo "<span style='right:5px;margin-top:-6px;position:absolute;color:white;font-weight:bold;font-size:18px;'>&#187;</span></a>";

            }
            else
            {
            ?>
            <a href="<?php echo $category['children'][$i]['href']; ?>" onmouseover='JavaScript:closeSubMenu()' ><?php echo $category['children'][$i]['name']; ?></a>
            <?php
            }
            ?>

            <?php if ($category['children'][$i]['children_level2']) { ?>
                 <div class="submenu" style="display:none;" id="id_menu_<?php echo $category['children'][$i]['id']; ?>">
                  <ul>
                  <?php for ($wi = 0; $wi < count($category['children'][$i]['children_level2']); $wi++) { ?>
                    <li>
                        <!-- Begin 4th level -->
<?php
            if(count($category['children'][$i]['children_level2'][$wi]['children_level3'])>0){
            ?>
                  <a href="<?php echo $category['children'][$i]['children_level2'][$wi]['href']; ?>"  ><?php echo $category['children'][$i]['children_level2'][$wi]['name']; ?></a>
            <?php

                  //echo "<img src='catalog/view/theme/default/image/arrow-right.png' style='right:10px;margin-top:3px;position:absolute;'/></a>";
                  //echo "<span style='right:5px;margin-top:-6px;position:absolute;color:white;font-weight:bold;font-size:18px;'>&#187;</span></a>";

            }
            else
            {
            ?>
            <a href="<?php echo $category['children'][$i]['children_level2'][$wi]['href']; ?>"  ><?php echo $category['children'][$i]['children_level2'][$wi]['name']; ?></a>
            <?php
            }
            ?>

            <?php if ($category['children'][$i]['children_level2'][$wi]['children_level3']) { ?>
                 <div class="submenu"  syule="display:none;" id="id_menu_<?php echo $category['children'][$i]['children_level2'][$wi]['id']; ?>">
                  <ul>
                  <?php for ($wid = 0; $wid < count($category['children'][$i]['children_level2'][$wi]['children_level3']); $wid++) { ?>
                    <li>
                        <a href="<?php echo $category['children'][$i]['children_level2'][$wid]['children_level3']['href']; ?>"  ><?php echo $category['children'][$i]['children_level2'][$wi]['children_level3'][$wid]['name']; ?>
                        </a>
                    </li>
              <?php } ?>
            </ul>
           </div>
<?php } ?>   

<!-- End 4th Level -->
                    </li>
              <?php } ?>
            </ul>
           </div>
           <?php } ?>        
         </li>
         <!-- END Part 1 of the extension Header menu add level 3 sub categories extension -->
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
<?php } ?>
<div id="notification"></div>
<!-- Begin Part 2 of the extension Header menu add level 3 sub categories extension-->
<script type="text/javascript">
function openSubMenu(id){
        //
        $('.submenu').hide();
        document.getElementById("id_menu_"+id).style.display="block";
}
function closeSubMenu(){
      $('.submenu').hide();
}
</script>
<style>
.submenu{
    background: url('catalog/view/theme/default/image/menu.png') repeat scroll 0 0 transparent;
        border: 1px solid #000000;
    border-radius: 0px 5px 5px 0px;
    margin-top:-23px;
    left:140px;
    position:absolute;
    min-width:140px;
    display:none;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
 .submenu {left: 160px;}

    }
</style>


<!-- PHONE::Start -->

<?php if ($categories) { ?>
<div id="menu-phone" class="shown-phone" style="display: none;">
  <div id="menu-phone-button">Menu</div>
  <select id="menu-phone-select" onchange="location = this.value">
    <option value=""></option>
    <?php foreach ($categories as $category) { ?>
    <option value="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></option>
    <?php } ?>
  </select>
</div>

<script type="text/javascript">
    // Bind the Phone menu dropdown
    $('#menu-phone-button').bind('click', function() {
        $("#menu-phone-select").css({'opacity':'1'});
    });
</script>
<?php } ?>

<!-- PHONE::End -->

<div id="notification"></div>

并将您的 header.php 文件更改为

<?php   
class ControllerCommonHeader extends Controller {
   protected function index() {
      $this->data['title'] = $this->document->getTitle();

      if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
         $this->data['base'] = $this->config->get('config_ssl');
      } else {
         $this->data['base'] = $this->config->get('config_url');
      }

      $this->data['description'] = $this->document->getDescription();
      $this->data['keywords'] = $this->document->getKeywords();
      $this->data['links'] = $this->document->getLinks();    
      $this->data['styles'] = $this->document->getStyles();
      $this->data['scripts'] = $this->document->getScripts();
      $this->data['lang'] = $this->language->get('code');
      $this->data['direction'] = $this->language->get('direction');
      $this->data['google_analytics'] = html_entity_decode($this->config->get('config_google_analytics'), ENT_QUOTES, 'UTF-8');

      // Whos Online
      if ($this->config->get('config_customer_online')) {
         $this->load->model('tool/online');

         if (isset($this->request->server['REMOTE_ADDR'])) {
            $ip = $this->request->server['REMOTE_ADDR'];   
         } else {
            $ip = ''; 
         }

         if (isset($this->request->server['HTTP_HOST']) && isset($this->request->server['REQUEST_URI'])) {
            $url = 'http://' . $this->request->server['HTTP_HOST'] . $this->request->server['REQUEST_URI'];   
         } else {
            $url = '';
         }

         if (isset($this->request->server['HTTP_REFERER'])) {
            $referer = $this->request->server['HTTP_REFERER'];   
         } else {
            $referer = '';
         }

         $this->model_tool_online->whosonline($ip, $this->customer->getId(), $url, $referer);
      }

      $this->language->load('common/header');

      if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
         $server = HTTPS_IMAGE;
      } else {
         $server = HTTP_IMAGE;
      }   

      if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) {
         $this->data['icon'] = $server . $this->config->get('config_icon');
      } else {
         $this->data['icon'] = '';
      }

      $this->data['name'] = $this->config->get('config_name');

      if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
         $this->data['logo'] = $server . $this->config->get('config_logo');
      } else {
         $this->data['logo'] = '';
      }

      $this->data['text_home'] = $this->language->get('text_home');
      $this->data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
      $this->data['text_shopping_cart'] = $this->language->get('text_shopping_cart');
       $this->data['text_search'] = $this->language->get('text_search');
      $this->data['text_welcome'] = sprintf($this->language->get('text_welcome'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));
      $this->data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', 'SSL'), $this->customer->getFirstName(), $this->url->link('account/logout', '', 'SSL'));
      $this->data['text_account'] = $this->language->get('text_account');
       $this->data['text_checkout'] = $this->language->get('text_checkout');

      $this->data['publisher_sign'] = $this->url->link('account/publisher_signup', '', 'SSL');

      $this->data['developer_sign'] = $this->url->link('account/developer_signup', '', 'SSL');

      $this->data['home'] = $this->url->link('common/home');
      $this->data['wishlist'] = $this->url->link('account/wishlist', '', 'SSL');
      $this->data['logged'] = $this->customer->isLogged();
      $this->data['account'] = $this->url->link('account/account', '', 'SSL');
      $this->data['shopping_cart'] = $this->url->link('checkout/cart');
      $this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');

      if (isset($this->request->get['filter_name'])) {
         $this->data['filter_name'] = $this->request->get['filter_name'];
      } else {
         $this->data['filter_name'] = '';
      }

      // Menu
      $this->load->model('catalog/category');

      $this->load->model('catalog/product');

      $this->data['categories'] = array();

      $categories = $this->model_catalog_category->getCategories(0);

      foreach ($categories as $category) {
         if ($category['top']) {
            $children_data = array();

            $children = $this->model_catalog_category->getCategories($category['category_id']);

            foreach ($children as $child) {
               $data = array(
                  'filter_category_id'  => $child['category_id'],
                  'filter_sub_category' => true
               );               
               /*Begin of the extension Header menu add level 3 sub categories extension code  to be replaced:
               $product_total = $this->model_catalog_product->getTotalProducts($data); 

               $children_data[] = array(
                  'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
                  'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])   
               );   
               */             
               // Level 2
               $children_level2 = $this->model_catalog_category->getCategories($child['category_id']);
               $children_data_level2 = array();
               foreach ($children_level2 as $child_level2) {
                     $data_level2 = array(
                           'filter_category_id'  => $child_level2['category_id'],
                           'filter_sub_category' => true
                     );

                     //level3 starts here

                     $children_level3 = $this->model_catalog_category->getCategories($child_level2['category_id']);
                     $children_data_level3 = array();
                     foreach ($children_level3 as $child_level3) 
                        {
                           $data_level3 = array(
                                 'filter_category_id'  => $child_level3['category_id'],
                                 'filter_sub_category' => true
                           );
                           $product_total_level3 = '';
                           if ($this->config->get('config_product_count')) {
                                 $product_total_level3 = ' (' . $this->model_catalog_product->getTotalProducts($data_level3) . ')';
                           }

                           $children_data_level3[] = array(
                                 'name'  =>  $child_level3['name'] . $product_total_level3,
                                 'href'  => $this->url->link('product/category', 'path=' . $child['category_id'] . '_' . $child_level3['category_id']),
                                 'id' => $category['category_id']. '_' . $child['category_id']. '_' . $child_level3['category_id']
                           );
                        }
                     //level 3 ends here
                     $product_total_level2 = '';
                     if ($this->config->get('config_product_count')) {
                           $product_total_level2 = ' (' . $this->model_catalog_product->getTotalProducts($data_level2) . ')';
                     }

                     $children_data_level2[] = array(
                           'name'  =>  $child_level2['name'] . $product_total_level2,
                           'href'  => $this->url->link('product/category', 'path=' . $child['category_id'] . '_' . $child_level2['category_id']),
                           'id' => $category['category_id']. '_' . $child['category_id']. '_' . $child_level2['category_id'],
                           'children_level3' => $children_data_level3,
                     );
               }
               $children_data[] = array(
                     'name'  => $child['name'],
                     'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
                     'id' => $category['category_id']. '_' . $child['category_id'],
                     'children_level2' => $children_data_level2,
               );
               //END of the extension Header menu add level 3 sub categories extension         
            }

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

         }
      }

      if (isset($this->request->get['filter_category_id'])) {

         $filter_category_id = $this->request->get['filter_category_id'];

      } else {

         $filter_category_id = 0;

      }

      $this->data['filter_category_id'] = $filter_category_id;



      foreach ($categories as $category) {

            $children_data = array();



            $children = $this->model_catalog_category->getCategories($category['category_id']);



            foreach ($children as $child) {

               $data = array(

                     'filter_category_id'  => $child['category_id'],

                     'filter_sub_category' => true

               );



               $product_total = $this->model_catalog_product->getTotalProducts($data);



               $children_data[] = array(

                     'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),

                     'category_id' => $child['category_id']

               );

            }



            // Level 1

            $this->data['categories_search'][] = array(

                  'name'     => $category['name'],

                  'category_id' => $category['category_id'],

                  'children' => $children_data,

            );



      }


      $this->children = array(
         'module/language',
         'module/currency',
         'module/cart'
      );

      if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/common/header.tpl';
      } else {
         $this->template = 'default/template/common/header.tpl';
      }

       $this->render();
   }    
}
?>
于 2013-01-22T12:01:48.070 回答