1

I have the following XML in my module params:

<field name="menulink" type="menuitem" default="45" label="Select a menu item to show" description="Select a menu item" />

If I echo

$menulink;

Then it shows the ID of the menu in the frontend, how can I get the menu name too?

1 Answer 1

3

You can use the following:

$menu = Joomla\CMS\Factory::getApplication()->getMenu();
$menuItem = $menu->getItem($menulink);

echo $menuItem->title;

If you var_dump($menuItem);, it will show you which properties are available for said menu item.

1
  • Perfect! Thank you Commented Jul 20, 2021 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.