1)
视图:
<select name="command">
<option>选择操作</option>
<?php foreach ((array)$datalist as $row):?>
<option><?php echo $row['str_repeat'].$row['catalog_name_alias'] ?></option>
<?php endforeach;?>
</select>
2.控制器里面去取$datalist:
$datalist = Catalog::get(0, $this->_catalog);(父id为0的,说明是所有)
3.catalog模型里面的函数:
/** * 取分类 */ static public function get($parentid = 0, $array = array(), $level = 0, $add = 2, $repeat = '-') { $str_repeat = ''; if ($level) { for($j = 0; $j < $level; $j ++) { $str_repeat .= $repeat; } } $newarray = array (); $temparray = array (); foreach ( ( array ) $array as $v ) { if ($v ['parent_id'] == $parentid) { $newarray [] = array ('id' => $v ['id'], 'catalog_name' => $v ['catalog_name'], 'catalog_name_alias' => $v ['catalog_name_alias'], 'parent_id' => $v ['parent_id'], 'level' => $level, 'sort_order' => $v ['sort_order'], 'seo_keywords' => $v ['seo_keywords'], 'seo_description' => $v ['seo_description'], 'attach_file' => $v ['attach_file'], 'attach_thumb' => $v ['attach_thumb'], 'status_is' => $v ['status_is'], 'data_count' => $v ['data_count'] , 'display_type' => $v ['display_type'], 'menu_is' => $v ['menu_is'], 'template_list' => $v ['template_list'],'acl_browser' => $v ['acl_browser'], 'acl_operate' => $v ['acl_operate'],'template_page' => $v ['template_page'], 'template_show' => $v ['template_show'],'create_time' => $v ['create_time'], 'str_repeat' => $str_repeat, 'page_size'=>$v['page_size'] ); $temparray = self::get ( $v ['id'], $array, ($level + $add) ); if ($temparray) { $newarray = array_merge ( $newarray, $temparray ); } } } return $newarray; }