// Lấy menu từ các chức năng của module $funcs_item = $site_mods[$mod_name]['funcs']; foreach ($funcs_item as $key => $sub_item) { if ($sub_item['in_submenu'] == 1) { $array_item[] = array('key' => $key, 'title' => $sub_item['func_custom_name'], 'alias' => $key); } } if (!empty($array_item)) { $xtpl = new XTemplate('rows.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); $xtpl->assign('LANG', $lang_module); foreach ($array_item as $key => $item1) { $parentid = isset($item1['parentid']) ? $item1['parentid'] : 0; if (empty($parentid)) { $item1['module'] = $mod_name; $xtpl->assign('item', $item1); $xtpl->parse('main.link.item'); $array_submenu = array(); nv_menu_get_submenu($key, '', $array_item, $sp); foreach ($array_submenu as $item2) { $xtpl->assign('item', $item2); $xtpl->parse('main.link.item'); } } } $xtpl->parse('main.link'); $contents = $xtpl->text('main.link'); include NV_ROOTDIR . '/includes/header.php'; echo $contents; include NV_ROOTDIR . '/includes/footer.php'; } die(' ');
foreach ($funcs_item as $key => $sub_item) { if ($sub_item['in_submenu'] == 1) { $array_item[$key] = array('key' => $key, 'title' => $sub_item['func_custom_name'], 'alias' => $key); } } if (!empty($array_item)) { foreach ($array_item as $key => $item) { $parentid = isset($item['parentid']) ? $item['parentid'] : 0; if (empty($parentid)) { $item['module'] = $mod_name; $item['selected'] = $item['alias'] == $post['op'] ? ' selected="selected"' : ''; $xtpl->assign('item', $item); $xtpl->parse('main.link.item'); if (isset($item['parentid'])) { $array_submenu = array(); nv_menu_get_submenu($key, $post['op'], $array_item, $sp); foreach ($array_submenu as $item2) { $xtpl->assign('item', $item2); $xtpl->parse('main.link.item'); } } } } } $xtpl->parse('main.link'); } } $arr_menu = nv_list_menu(); foreach ($arr_menu as $arr) { $xtpl->assign('key', $arr['id']); $xtpl->assign('val', $arr['title']);
/** * @param int $id * @param array $array_item * @param string $sp_i */ function nv_menu_get_submenu($id, $alias_selected, $array_item, $sp_i) { global $array_submenu, $sp, $mod_name; foreach ($array_item as $item2) { if (isset($item2['parentid']) and $item2['parentid'] == $id) { $item2['title'] = $sp_i . $item2['title']; $item2['module'] = $mod_name; $item2['selected'] = $item2['alias'] == $alias_selected ? ' selected="selected"' : ''; $array_submenu[] = $item2; nv_menu_get_submenu($item2['key'], $alias_selected, $array_item, $sp_i . $sp); } } }