Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. function view_tree()
  2.     {
  3.         $tree = $this->display_children(0, 0);
  4.         echo '<pre>'; print_r($tree); echo '<pre>';
  5.        
  6.     }
  7.     function display_children($parentID, $level)
  8.     {
  9.         $tree[]='heelllooo';
  10.         // get tasks at this level..
  11.         $task = new Task();
  12.         $task->include_related('tasktype', array('id', 'title', 'controller', 'colour'), TRUE, TRUE);
  13.         $task->include_related('flag', array('id', 'title', 'iconFile', 'colour'), TRUE, TRUE);
  14.         $task->where('parentTaskID', $parentID);
  15.         $task->get();
  16.         //$task is a object
  17.         if($task->count() > 0)
  18.         {
  19.             //echo 'im in';
  20.             foreach ($task as $aTask)
  21.             {
  22.                // indent and display the title of this child
  23.                 $tree[$aTask->id] = array( 
  24.                                         'id'        =>  $aTask->id,
  25.                                         'title'     =>  $aTask->title,
  26.                                         'object'    =>  $aTask
  27.                                         );
  28.                                    
  29.                // call this function again to display this
  30.                // child's children
  31.                $this->display_children($aTask->id, $level+1);
  32.            }
  33.         }
  34.        
  35.        
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement