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

Error: "No menu items found! Confirm that such a menu exists and that it has menu items." #50

Open
Mikhail-Kalinin2 opened this issue Oct 27, 2023 · 0 comments

Comments

@Mikhail-Kalinin2
Copy link

Mikhail-Kalinin2 commented Oct 27, 2023

Hello, @kongondo!

I use the module in this way: I'm creating a site with possibility of creating blank menu without items.

On these lines I'm trying to get menu items:

$menuBuilder = $this->modules->get('MarkupMenuBuilder');
$this->menuItems = $menuBuilder->getMenuItems($id);

Then I get an error: "No menu items found! Confirm that such a menu exists and that it has menu items." if items are not present. This is caused by the line 1366:

https://github.com/kongondo/MenuBuilder/blob/main/MarkupMenuBuilder.module#L1366

I tried to fix it manually using the fact that the menu is a page and menu items are being stored in menu_items variable:

$menuBuilder = $this->modules->get('MarkupMenuBuilder');
$menu = $this->pages->get($id);
if($menu->menu_items) {
	$this->menuItems = $menuBuilder->getMenuItems($id);
} else {
	return;
}

However, it seems to be only a workaround. Am I using module correctly? If no, how can I use it to avoid such an error without adding items?

If it is not possible, I suggest the following fix:

Here https://github.com/kongondo/MenuBuilder/blob/main/MarkupMenuBuilder.module#L1366 return can be replaced from $this->throwError() to [] or array().

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

1 participant