Cakephp 使用generatetreelist返回额外字段

Cakephp 使用generatetreelist返回额外字段,cakephp,Cakephp,我不知道我的树行为是否正确,但我正在尝试为博客构建一个评论系统。我想要一个5级深度的缩进 generatetreelist方法看起来是实现这一点的最快方法,但看起来不能向查询中添加字段。我说得对吗?有没有办法修改这个方法 谢谢如果是我,我会在结果集中这样做。当您在结果的第一个维度中获得一个数字数组时,您可以在输出数据时使用该数组,以便根据需要缩进或向注释中添加类。这就是我对类别的处理方式。您可以相应地修改 在控制器中: $categories = $this->Category->g

我不知道我的树行为是否正确,但我正在尝试为博客构建一个评论系统。我想要一个5级深度的缩进

generatetreelist方法看起来是实现这一点的最快方法,但看起来不能向查询中添加字段。我说得对吗?有没有办法修改这个方法


谢谢

如果是我,我会在结果集中这样做。当您在结果的第一个维度中获得一个数字数组时,您可以在输出数据时使用该数组,以便根据需要缩进或向注释中添加类。

这就是我对类别的处理方式。您可以相应地修改

在控制器中:

$categories = $this->Category->generatetreelist(null,null,null,"|-- ");
    $categories_array = array();
    foreach($categories as $k => $v)
    {
        $categories_array[$k] = $this->Category->find('first', array('conditions' => array('Category.id' => $k)));
        $categories_array[$k]["Category"]["path"] = $v;
    }

    $this->set(compact('categories','categories_array'));
鉴于:

    <table>
    <thead>
      <tr>
        <th><?php __('Id');?></th>
        <th><?php __('Name');?></th>
        <th><?php __('Status');?></th>
        <th><?php __('Action');?></th>
    </tr>
    </thead>
    <tbody>
    <?php
    $i = 0;
    foreach ($categories_array AS $categoryId => $category):
    $class = 'even';
    if ($i++ % 2 == 0) {
        $class = 'odd';
    }?>
    <tr class="<?php echo $class;?>">
    <td><?php echo $category['Category']['id']; ?></td>
    <td><?php echo $category["Category"]["path"];?></td>


    <?php if ($category['Category']['status'] == '1'){
    $published = 'Active';
        }else {
    $published = 'Inactive';
    } ?>
<td><?php echo $published;?></td>
<td>
 <?php echo $html->link($html->image("icons/16_icon_view.png"), array('action' => 'view', $category['Category']['id']), array('title'=>'View','escape' => false));?>&nbsp;
            <?php echo $html->link($html->image("icons/16_icon_edit.png"), array('action' => 'edit', $category['Category']['id']), array('title'=>'Edit','escape' => false));?>&nbsp;
            <?php echo $html->link($html->image("icons/16_icon_delete.png"), array('action' => 'delete', $category['Category']['id']), array('class'=>'delete_trigger','rel'=>'#error','title'=>'Delete','escape' => false));?>
        </td>
    </tr>

  <?php endforeach; ?>


</tbody>
</table>

我不太明白。您不会使用树行为吗?或者只有文章有多条评论关系。