Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions Themes/default/GenericMenu.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,30 +248,39 @@ function template_generic_menu_tabs(&$menu_context)
}

// Print out all the items in this tab (if any).
if (!empty(Utils::$context['tabs'])) {
// What gets drawn below is $tab_context['tabs'], and that is only assembled
// above when this menu has a title of its own. Utils::$context['tabs'] is
// set as a side effect of drawing the menu, so it can be full while this
// one is still empty, which produced an empty menu on those pages.
// Labels arrive from the loop above, and it only runs over the areas the
// menu itself knows about, so a page that forces tabs of its own can leave
// some without one. Those cannot be drawn, so they do not count towards
// having anything to draw either. Same treatment the areas above get.
$drawable_tabs = array_filter(
$tab_context['tabs'] ?? [],
fn($tab) => empty($tab['disabled']) && !empty($tab['label']),
);

if (!empty($drawable_tabs)) {
// The admin tabs.
echo '
<a class="mobile_generic_menu_', Utils::$context['cur_menu_id'], '_tabs">
<span class="menu_icon"></span>
<span class="text_menu">', Lang::getTxt('mobile_generic_menu', ['label' => $tab_context['title']], file: 'General'), '</span>
<span class="text_menu">', Lang::getTxt('mobile_generic_menu', ['label' => $tab_context['title'] ?? ''], file: 'General'), '</span>
</a>
<div id="adm_submenus">
<div id="mobile_generic_menu_', Utils::$context['cur_menu_id'], '_tabs" class="popup_container">
<div class="popup_window description">
<div class="popup_heading">
', Lang::getTxt('mobile_generic_menu', ['label' => $tab_context['title']], file: 'General'), '
', Lang::getTxt('mobile_generic_menu', ['label' => $tab_context['title'] ?? ''], file: 'General'), '
<a href="javascript:void(0);" class="main_icons hide_popup"></a>
</div>';

echo '
<div class="generic_menu">
<ul class="dropmenu dropdown_menu_', Utils::$context['cur_menu_id'], '_tabs">';

foreach ($tab_context['tabs'] as $sa => $tab) {
if (!empty($tab['disabled'])) {
continue;
}

foreach ($drawable_tabs as $sa => $tab) {
if (!empty($tab['is_selected'])) {
echo '
<li>
Expand Down
Loading