Using this in the controller: $this->set('category_tree', $category_tree);
Just produces this error: Undefined variable: category_tree in C:\wamp \www\cake\app\controllers\nodes_controller.php on line 47 I think this is correct: $this->set('category_tree', $this->Node- >generateNestedList('--', null)); I have a similar bit of code in the same controller which seems to work: $this->set('nodeTypes', $this->Node->NodeType->generateList()); // in the controller <?php echo $html->selectTag('Node/node_type_id', $nodeTypes, $html- >tagValue('Node/node_type_id'), array(), array(), true);?> // in the view The problem seems specific to the generateNestedList function, I just can't work it out. The snippet from Othy is just to advanced for a poor designer to understand ;( Cheers, Brett. On Mar 12, 8:16 pm, "Eric C Blount" <[EMAIL PROTECTED]> wrote: > $this->set('category_tree', $category_tree); //in the controller, so the > view can use the variable... > > HTH, > Eric > > On 3/11/07, double07 <[EMAIL PROTECTED]> wrote: > > > > > Hi all, > > > I just wanted to re-visit this again. I've come back after a couple of > > weeks break to attempt to finish this project, in particular the > > 'parent' select list which needs to be indented (for ease of use). Now > > I found what I thought was the perfect bit of code by 'Othy' here: > >http://othy.wordpress.com/2006/06/03/generatenestedlist/ > > > It's supposed to generate nested lists for use with select/drop downs. > > It's a bit light on the documentation and I'm having trouble getting > > it to work. > > > As per the instructions, in my app_controller.php file I put the > > following code: > > > function generateNestedList($indent = ' ',$sort = null) > > { > > $this->recursive = '-1'; > > $cats = $this->findAllThreaded(null, > > array($this->name.'.id',$this- > > >name.'.name',$this->name.'.parent_id'), $sort); > > $glist = $this->_generateNestedList($cats,$indent); return > > $glist; > > } > > function _generateNestedList($cats,$indent,$level = 0) > > { > > static $list = array(); > > for($i = 0, $c = count($cats); $i < $c; $i++) > > { > > $list[$cats[$i][$this->name]['id']] = > > str_repeat($indent,$level). > > $cats[$i][$this->name]['name']; if(isset($cats[$i]['children']) && ! > > empty($cats[$i]['children'])) > > { > > > $this->_generateNestedList($cats[$i]['children'],$indent,$level + > > 1); > > } > > } > > return $list; > > } > > > Now in my controller (called Nodes) I've got: > > > $this->set('category_tree', $this->Node->generateNestedList('--', > > null)); > > > This seems correct and doesn't produce any errors, however when I try > > to use the category_tree in a selectTag in my view, I get nothing: > > > <?php echo $html->selectTag('Node/parent_id', $category_tree, $html- > > >tagValue('Node/parent_id'), array(), array(), true);?> > > > If I just print_r $category tree, it's also empty. > > > Has anybody got experience with this snippet of code by Othy (I'd ask > > him directly but there doesn't seem to be any contact info on his > > page)? Or could somebody please give me some pointers??? Alternatively > > another method would be appreciated. > > > Thanks again, > > > Brett. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---