“Discuz!X/后台HTML显示函数”的版本间的差异
来自Blueidea
< Discuz!X
1033289127(讨论 | 贡献) (→导航显示函数(shownav)) |
1033289127(讨论 | 贡献) |
||
第43行: | 第43行: | ||
//品网后台导航显示 | //品网后台导航显示 | ||
shownav('pages', 'menu_pages_sortoption'); | shownav('pages', 'menu_pages_sortoption'); | ||
+ | |||
+ | |||
+ | == 子菜单显示函数(showsubmenu) == | ||
+ | |||
+ | *函数原型 | ||
+ | <syntaxhighlight lang="php"> | ||
+ | function showsubmenu($title, $menus = array(), $right = '', $replace = array()) { | ||
+ | if(empty($menus)) { | ||
+ | $s = '<div class="itemtitle">'.$right.'<h3>'.cplang($title, $replace).'</h3></div>'; | ||
+ | } elseif(is_array($menus)) { | ||
+ | $s = '<div class="itemtitle">'.$right.'<h3>'.cplang($title, $replace).'</h3>'; | ||
+ | if(is_array($menus)) { | ||
+ | $s .= '<ul class="tab1">'; | ||
+ | foreach($menus as $k => $menu) { | ||
+ | if(is_array($menu[0])) { | ||
+ | $s .= '<li id="addjs'.$k.'" class="'.($menu[1] ? 'current' : 'hasdropmenu').'" onmouseover="dropmenu(this);"><a href="#"><span>'.cplang($menu[0]['menu']).'<em> </em></span></a><div id="addjs'.$k.'child" class="dropmenu" style="display:none;">'; | ||
+ | if(is_array($menu[0]['submenu'])) { | ||
+ | foreach($menu[0]['submenu'] as $submenu) { | ||
+ | $s .= $submenu[1] ? '<a href="'.ADMINSCRIPT.'?action='.$submenu[1].'" class="'.($submenu[2] ? 'current' : '').'" onclick="'.$submenu[3].'">'.cplang($submenu[0]).'</a>' : '<a><b>'.cplang($submenu[0]).'</b></a>'; | ||
+ | } | ||
+ | } | ||
+ | $s .= '</div></li>'; | ||
+ | } else { | ||
+ | $s .= '<li'.($menu[2] ? ' class="current"' : '').'><a href="'.(!$menu[4] ? ADMINSCRIPT.'?action='.$menu[1] : $menu[1]).'"'.(!empty($menu[3]) ? ' target="_blank"' : '').'><span>'.cplang($menu[0]).'</span></a></li>'; | ||
+ | } | ||
+ | } | ||
+ | $s .= '</ul>'; | ||
+ | } | ||
+ | $s .= '</div>'; | ||
+ | } | ||
+ | echo !empty($menus) ? '<div class="floattop">'.$s.'</div><div class="floattopempty"></div>' : $s; | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | *参数解释 | ||
+ | $title 二级导航标题 | ||
+ | $menus 展示的二级菜单(数组) | ||
+ | *使用范例 | ||
+ | showsubmenu('menu_pages_sortoption'); |
2011-07-08T11:23:59的版本
discuzx 后台模块开发大多直接调用后台HTML函数输出,使用HTML输出函数更加方便快捷的构建一个后台WEB页面。
- 函数原型
function shownav($header = '', $menu = '', $nav = '') { global $action, $operation; $title = 'cplog_'.$action.($operation ? '_'.$operation : ''); if(in_array($action, array('home', 'custommenu'))) { $customtitle = ''; } elseif(cplang($title, false)) { $customtitle = $title; } elseif(cplang('nav_'.($header ? $header : 'index'), false)) { $customtitle = 'nav_'.$header; } else { $customtitle = rawurlencode($nav ? $nav : ($menu ? $menu : '')); } $title = cplang('header_'.($header ? $header : 'index')).($menu ? ' » '.cplang($menu) : '').($nav ? ' » '.cplang($nav) : ''); $ctitle = cplang('header_'.($header ? $header : 'index')); if($menu) { $ctitle = cplang($menu); } if($nav) { $ctitle = cplang($nav); } $addtomenu = " <a target=\"main\" title=\"".cplang('custommenu_addto')."\" href=\"".ADMINSCRIPT."?action=misc&operation=custommenu&do=add&title=".rawurlencode($ctitle)."&url=".rawurlencode(cpurl())."\">[+]</a>"; $dtitle = str_replace("'", "\'", cplang('admincp_title').' - '.str_replace(' » ', ' - ', $title)); echo '<script type="text/JavaScript">parent.document.title = \''.$dtitle.'\';if(parent.$(\'admincpnav\')) parent.$(\'admincpnav\').innerHTML=\''.$title.$addtomenu.'\';</script>'; }
- 参数解释
$header 导航模块名 $menu 菜单 $nav 当前导航名
- 使用范例
//品网后台导航显示 shownav('pages', 'menu_pages_sortoption');
- 函数原型
function showsubmenu($title, $menus = array(), $right = '', $replace = array()) { if(empty($menus)) { $s = '<div class="itemtitle">'.$right.'<h3>'.cplang($title, $replace).'</h3></div>'; } elseif(is_array($menus)) { $s = '<div class="itemtitle">'.$right.'<h3>'.cplang($title, $replace).'</h3>'; if(is_array($menus)) { $s .= '<ul class="tab1">'; foreach($menus as $k => $menu) { if(is_array($menu[0])) { $s .= '<li id="addjs'.$k.'" class="'.($menu[1] ? 'current' : 'hasdropmenu').'" onmouseover="dropmenu(this);"><a href="#"><span>'.cplang($menu[0]['menu']).'<em> </em></span></a><div id="addjs'.$k.'child" class="dropmenu" style="display:none;">'; if(is_array($menu[0]['submenu'])) { foreach($menu[0]['submenu'] as $submenu) { $s .= $submenu[1] ? '<a href="'.ADMINSCRIPT.'?action='.$submenu[1].'" class="'.($submenu[2] ? 'current' : '').'" onclick="'.$submenu[3].'">'.cplang($submenu[0]).'</a>' : '<a><b>'.cplang($submenu[0]).'</b></a>'; } } $s .= '</div></li>'; } else { $s .= '<li'.($menu[2] ? ' class="current"' : '').'><a href="'.(!$menu[4] ? ADMINSCRIPT.'?action='.$menu[1] : $menu[1]).'"'.(!empty($menu[3]) ? ' target="_blank"' : '').'><span>'.cplang($menu[0]).'</span></a></li>'; } } $s .= '</ul>'; } $s .= '</div>'; } echo !empty($menus) ? '<div class="floattop">'.$s.'</div><div class="floattopempty"></div>' : $s; }
- 参数解释
$title 二级导航标题 $menus 展示的二级菜单(数组)
- 使用范例
showsubmenu('menu_pages_sortoption');