Php 在开放式购物车中显示第三类;遍历多维数组时未定义索引

Php 在开放式购物车中显示第三类;遍历多维数组时未定义索引,php,arrays,multidimensional-array,opencart,Php,Arrays,Multidimensional Array,Opencart,我试图在open cart中显示类别的第三级。以下是显示$data['categories'][0]['children']时的数组 Array ( [0] => Array ( [name] => HTC [href] => http://127.0.0.1/oc/mobile_phones/HTC [sec_children] => Array ( [0]

我试图在open cart中显示类别的第三级。以下是显示$data['categories'][0]['children']时的数组

Array
(
[0] => Array
    (
        [name] => HTC
        [href] => http://127.0.0.1/oc/mobile_phones/HTC
        [sec_children] => Array
            (
                [0] => Array
                    (
                        [name] => Desire
                        [href] => http://127.0.0.1/oc/HTC/HTC_Desire
                    )

                [1] => Array
                    (
                        [name] => One
                        [href] => http://127.0.0.1/oc/HTC/HTC_One
                    )

                [2] => Array
                    (
                        [name] => Windows
                        [href] => http://127.0.0.1/oc/HTC/HTC_Windows
                    )

            )

    )

[1] => Array
    (
        [name] => iPhone
        [href] => http://127.0.0.1/oc/mobile_phones/iPhone
        [sec_children] => Array
            (
            )
    )

   )
下面是header.php中的代码

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

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

            //'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),                
            foreach ($cat as $child) {
                //3rd level begin
                $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') ? ' (' . $product_total . ')' : ''),
                    'href'  => $this->url->link('product/category', 'path=' . $child['category_id'] . '_' . $sec_child['category_id'])  
                       );
                    }                       
                //3rd level end
                $filter_data = array(
                    'filter_category_id'  => $child['category_id'],
                    'filter_sub_category' => true
                );

                $kids_data[] = array(

                    'name'      => $child['name'],
                    'href'      => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
                    'sec_children'      => $sec_children_data //level 3 
                );
                //$this->load->test($kids_data);
            }

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

        <li class="level0<?php if($category['category_id'] == $category_id){ echo " active";} ?>"><a href="<?php echo $category['href']; ?>" <?php if($category['children']){ echo "class='parent'";} ?>><?php echo $category['name']; ?></a>

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

                <ul>

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

                      <?php if ($child['category_id'] == $child_id) { ?>

                        <li><a href="<?php echo $child['href']; ?>" class="active"><?php echo $child['name']; ?></a></li>

                      <?php } else { ?>

                        <li><a href="<?php echo $child['href']; ?>"><i class="fa fa-chevron-right"></i><?php echo $child['name']; ?></a></li>

                      <?php } ?>

                    <!-- level 3 -->
                       <?php if ($child['sec_children']) { ?>
                        <ul>
                            <?php foreach ($child['sec_children'] as $subChild) { ?>    
                                <li><a href="<?php echo $subChild['href']; ?>" class="active"><?php echo $subChild['name']; ?></a></li>
                            <?php } ?>
                        </ul>
                       <?php } ?>
                    <!-- level 3 -->

                  <?php } ?>

                 </ul>

            <?php } ?>

        </li>

  <?php } ?>
显示以下错误->未定义索引:sec_子项。虽然它在阵列中清晰显示。。。
我无法把它分类。。。。请建议

在tpl的第一行之前使用打印,然后退出。我很确定你没有得到整个数组的secu子元素。您必须使用vqmod或直接编辑opencart文件才能使其正常工作。查看catalog/controller/module/category.php.Thank@Alex;事情解决了