Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hidden sub-menue item breaks menu-structur #522

Open
HoozeMe opened this issue Apr 3, 2018 · 4 comments
Open

Hidden sub-menue item breaks menu-structur #522

HoozeMe opened this issue Apr 3, 2018 · 4 comments

Comments

@HoozeMe
Copy link

HoozeMe commented Apr 3, 2018

If the last submenu item is set to 'hidden' (not shown), the ul/li - stuctur is broken
Threfore I added the closing statment before continue:

if ($menu_show!=1) {
	// ** ... Hack fixing the problem of a last item that is hidden 
	if ($item->shallower) 
		echo str_repeat('</ul></li>', $item->level_diff);
	// ***
continue;
}

Now ist works, but ...
... if there is only one sub-item and this is hidden, the 'caret' is still shown.

To fix this 'quick and dirty' I compare in the type-functions a small hint from the menu-item-note.

if($item->deeper && $item->level < 2 && strpos($item->note, 'NODEEP') === false ){
	$class    .= ' dropdown-toggle';
	$dropdown  = ' data-toggle="dropdown"';
	$caret     = '<em class="caret"></em>';
}

My changes work ;) ... but only until the next update.

I propose a recursive buildup of the menu instead of the linear one in the function render($list). Then you know exactly whether an item is displayed and whether whole submenus may be empty and no dropdowns are to be displayed (not use $item->deeper, this could be hidden).

@HoozeMe
Copy link
Author

HoozeMe commented Nov 1, 2018

Sorry for late answer ... today an update of T3 reminded me of that bug.
I try to prepare an environment with that problem - but I had to fix it on our live-website immediately.

Here some screenshots...
This is the menu configuration:
menu configuration

'Kinder', 'Music' are 1st level entries; but because of the hidden entry they are put below the 'Gemeinde'-Entry

So it looks with original code:
broken menue

So it looks with my hack: Almost okay :)
menue with fix

@grantg182
Copy link

This issue still exists. Hack fix as above works, but not really a solution.

@altcom-neil
Copy link

altcom-neil commented Jan 14, 2021

Hi,
Just spent hours trying to work out why my menu was suddenly broken after turning off MegaMenu which seems to hide the bug.

They have added:

//intergration with new params joomla 3.6.x (menu_show)
$menu_show = (int)$item->params->get('menu_show', 1);
if ($menu_show!=1)
    continue;

to T3BootstrapTpl::render() but this is the wrong place for this code - by now the array of menu items should just be rendered.
If you compare the code with how the core ModMenuHelper::getList() works the array of menu items should already have excluded the hidden menu item before passing it to the render function.
The code above should be removed from T3BootstrapTpl::render() and instead the correct code mirroring how ModMenuHelper::getList() works should be added to T3Bootstrap::getList()

Here is the git patch for the file in our site:
T3Bootstrap-fix-hidden-sub-menu-item-bug.patch.txt

It adds the $hidden_parents array:

	// Get active menu item
	$items = $menu->getItems('menutype', $this->menutype);
	$hidden_parents = array(); // Bug fix for issue 522
	$lastitem = 0;

plus adds exactly the same menu_show check as the core file before the $item->parent = ... line :

            // Exclude item with menu item option set to exclude from menu modules - Bug fix for issue 522
            if (($item->params->get('menu_show', 1) == 0) || in_array($item->parent_id, $hidden_parents))
            {
                $hidden_parents[] = $item->id;
                unset($items[$i]);
                continue;
            }

This fixes the broken menu html for our site.

@grantg182
Copy link

Thanks @altcom-neil - I've committed this to master here though judging by outstanding PR's, I doubt this will ever get merged 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@grantg182 @HoozeMe @altcom-neil and others