I am new to CakePHP and this function so please help me as you can.
generatetreelist(null, null,'{n}.Category.name', ' - ');
this shows categories name and childrens perfect but I want 开发者_运维知识库to show my all fields of my categories in my index.ctp
. For example name(already showing), status.
if you could solve my problem? please do it...
in my view I used:
foreach($categories as $key=>$value) {
echo $value;//it shows just name..
}
in my controller:
$nCategories = $this->Category->generatetreelist(null, '{n}.Category.id','{n}.Category.name', ' - ');
$this->set(compact('nCategories',$this->paginate('Category')));
you want to use find('threaded'), not generatetree list ()
$params = array(
'recursive' => -1,
'fields' => 'Category.id, Category.name, Category.parent_id',
);
$categories = $this->Category->find('threaded',$params);
debug($categories);
精彩评论