我在做tree tutorial並希望在視圖中顯示數據並將其包裝在html等中。我是Cake PHP的新手,這已經有點兒了的痛苦。下面是我嘗試過的一個例子。總之,我想我可以使用set將輸出分配給一個變量。我做錯了一切。如何在Cake的視圖中顯示'tree'數據PHP
控制器
<?php
class CategoriesController extends AppController {
public function index() {
$this->set('output', $this->Category->generateTreeList(null, null, null, ' '));
}
}
?>
查看
<?php foreach ($output as $data): ?>
<div><?php echo $data['Category']['name']; ?></div>
<?php endforeach; ?>
<?php unset($data); ?>
提示:CakePHP的和樹結構/(HTTP ://www.dereuromark.de/2013/02/17/cakephp-and-tree-structures/) – mark