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?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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