0

コードで包含可能な動作を使用しましたが、それも機能しています。print_r を書き込むと、期待どおりに配列が表示されますが、問題はそのデータをビュー/インデックスページに表示する方法です

これが私のコードです

subsubcategoriescontroller.php

$this->loadModel('Category');

$this->Subsubcategory->recursive = 0;

$this->Category->find('all', array('contain' => array('Subcategory', 'Subcategory.Subsubcategory')));

これが私のサブサブカテゴリビュー/インデックスページです

<table class="table table-striped dataTable table-hover table-bordered" id="sample_editable_1" style="font-size: 13px;">
<thead>
    <tr>
    <th><?php echo $this->Paginator->sort('id'); ?></th>
<!--            <th><?php echo $this->Paginator->sort('subcategory_id'); ?></th>
        <th><?php echo $this->Paginator->sort('name'); ?></th>
        <th><?php echo $this->Paginator->sort('arabic_name'); ?></th>-->
        <th><?php echo $this->Paginator->sort('name'); ?></th>

        <th><?php echo $this->Paginator->sort('subcategory_id'); ?></th>
        <!--<th><?php echo $this->Paginator->sort('category_id'); ?></th>-->
        <th class="actions"><?php echo __('Actions'); ?></th>
    </tr>
</thead>
<tbody>
    <?php foreach ($subsubcategories as $subsubcategory): ?>
    <tr>
            <td><?php echo h($subsubcategory['Subsubcategory']['id']); ?>&nbsp;</td>
            <td><?php echo h($subsubcategory['Subsubcategory']['name']); ?>&nbsp;</td>
             <td>
                    <?php echo $this->Html->link($subsubcategory['Category']['name'], array('controller' => 'categories', 'action' => 'view', $subsubcategory['Category']['id'])); ?>
            </td>
           <td>
                    <?php echo $this->Html->link($subsubcategory['Subcategory']['name'], array('controller' => 'subcategories', 'action' => 'view', $subsubcategory['Subcategory']['id'])); ?>
            </td>
            <!--<td>
                    <?php echo $this->Html->link($subsubcategory['Category']['name'], array('controller' => 'subcategories', 'action' => 'view', $subsubcategory['Subcategory']['id'])); ?>
            </td>-->
           <!-- <td><?php echo h($subsubcategory['Subsubcategory']['arabic_name']); ?>&nbsp;</td>-->
            <td><?php echo $this->Html->link(__('View'), array('action' => 'view', $subsubcategory['Subsubcategory']['id']), array('class'=>'btn yellow')); ?></td>
            <td><?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $subsubcategory['Subsubcategory']['id']), array('class'=>'btn green')); ?></td>
            <td><?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $subsubcategory['Subsubcategory']['id']), array('class'=>'btn red'), null, __('Are you sure you want to delete # %s?', $subsubcategory['Subsubcategory']['id'])); ?></td>
           </tr>
</tbody>
<?php endforeach; ?>

しかし、それは私にエラーを与えています

通知 (8): 未定義のインデックス: サブカテゴリ [APP/View/Categories/index.ctp、39 行目]

誰でも助けることができますか?

私はこのような配列を与えています

Array
(
    [0] => Array
        (
            [Category] => Array
                (
                    [id] => 1
                    [name] => cat
                    [arabic_name] => cat
                )

            [Subcategory] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [category_id] => 1
                            [name] => subcat
                            [arabic_name] => subcat
                            [Subsubcategory] => Array
                                (
                                    [0] => Array
                                        (
                                            [id] => 1
                                            [subcategory_id] => 1
                                            [name] => SubSubCategory
                                            [arabic_name] => SubSubCategory
                                        )

                                )

                        )

                )

        )

)
4

1 に答える 1