public function _before_edit() { $map['id'] = $_REQUEST['id']; $node = new NodeModel(); $menu = $node->getMenu(); $pid = $node->where($map)->getField('pid'); $selecttree = outNodeSelect($menu, $pid); $this->assign('selecttree', $selecttree); }
function outNodeSelect($tree, $currentid) { $html = ''; foreach ($tree as $t) { if (empty($t['pid'])) { if ($currentid == $t['id']) { $html .= '<option value="' . $t['id'] . '" selected="selected">'; } else { $html .= '<option value="' . $t['id'] . '">'; } for ($i = 1; $i < $t['level']; $i++) { $html .= ' '; if ($i == $t['level'] - 1) { $html .= '|-'; } } $html .= $t['title']; $html .= '</option>'; } else { if ($currentid == $t['id']) { $html .= '<option value="' . $t['id'] . '" selected="selected">'; } else { $html .= '<option value="' . $t['id'] . '">'; } for ($i = 1; $i < $t['level']; $i++) { $html .= ' '; if ($i == $t['level'] - 1) { $html .= '|-'; } } $html .= $t['title']; $html .= '</option>'; $html .= outNodeSelect($t['pid'], $currentid); } } return $html; }