0

我正在尝试将链接添加到树输出列表。

除了链接之外,我还得到 了输出中包含的 

所以它看起来像这样:

**My Categories
   Fun
      Sport
         Surfing
         Extreme knitting**

ETC.....

显然我不想这样,但我确实想保持嵌套的输出关系。

下面是代码:

控制器

<?php

class CategoriesController extends AppController {
 public $helpers = array('Html', 'Form');

    public function index() {

      $this->set('output', $this->Category->generateTreeList(null, null, null, '&nbsp;&nbsp;&nbsp;'));
    }
}

?>

看法

<?php foreach ($output as $data): ?>
<ul>

<?php echo $this->Html->link($data,
array('controller' => 'data', 'action' => 'view', $data)); ?>



</ul>
    <?php endforeach; ?>
    <?php unset($data); ?>
4

1 回答 1

0

您应该使用树助手将您的树输出为 ul/li,包括链接。见http://www.dereuromark.de/2013/02/17/cakephp-and-tree-structures/

generateTreeList() - 如文档所述 - 是创建下拉选择就绪列表的快速方法,而不是树。

于 2013-10-04T20:31:50.690 回答