Hi everybody,
I try to make a multidimensionnal array with my data on my database to create a CTreeview.
Here an exemple :
// CTREEVIEW
<?php
$this->widget('CTreeView',array(
'data'=>$dataTree,
'animated'=>'fast', //quick animation
'collapsed'=>'false',//remember must giving quote for boolean value in here
'htmlOptions'=>array(
'class'=>'treeview-red',//there are some classes that ready to use
),
));
?>
//ARRAY
<?php
$dataTree=array(
array(
'text'=>'Grampa', //must using 'text' key to show the text
'children'=>array(//using 'children' key to indicate there are children
array(
'text'=>'Father',
'children'=>array(
array('text'=>'me'),
array('text'=>'big sis'),
array('text'=>'little brother'),
)
),
array(
'text'=>'Uncle',
'children'=>array(
array('text'=>'Ben'),
array('text'=>'Sally'),
)
),
array(
'text'=>'Aunt',
)
)
)
);?>
The only problem is that I don’t know how to make that kind of multidimensionnal array.
My Table :
Node
id
levelOneId
levelTwoId
levelThreeId
revisionId
Here some crapy code, the problem is showing only the last node
<?php
foreach($nodes as $node){
$tree = array(
array(
'text' => trim($node->levelOneName),
'children' => array(
array(
'text' => trim($node->levelTwoName),
'children' => array(
array(
'text' => trim($node->levelThreeName),
'children' => array(
array(
'text' => CHtml::link(trim($node->revisionName),array('view','id'=>$node->id)),
)
)
)
)
)
)
)
);
}
$this->widget('CTreeView',array(
'data'=>$tree,
'animated'=>'fast', //quick animation
'collapsed'=>'false',//remember must giving quote for boolean value in here
'htmlOptions'=>array(
'class'=>'treeview-red',//there are some classes that ready to use
),
));
}
?>
Thanks for help