Joomla 3 get the menu title
13,972
Solution 1
Also you can use this one:
$menu = &Jsite::getMenu();
$menuname = $menu->getActive()->title;
or if already $app = JFactory::getApplication();
exist
$menu = $app->getMenu();
$menuname = $menu->getActive()->title;
Solution 2
The below code works for me in Joomla 3.0:
$app = JFactory::getApplication();
$menu = $app->getMenu();
$menuname = $menu->getActive()->title;
Solution 3
Use this:
/** Getting the Menu ID of Menu was clicked by user **/
$menu = &JSite::getMenu();
$id = $menu->getActive()->id;
/** Getting the Title of the Menu by using id. **/
$db = JFactory::getDBO();
$query = "SELECT title FROM kjs_menu WHERE id = $id";
$db->setQuery($query);
$rows = $db->loadObjectList();
$itemrow = $rows[0];
$title = $itemrow->title;
echo "Menu you have clicked is : ".$title;
Author by
user1915721
Updated on June 04, 2022Comments
-
user1915721 almost 2 years
I'm using multiple menus on one page. In multiple divs I'm showing a menu (menu1 to menu6). For templating purposes I would like to get the menu title of each menu to show on top. I'm not managing to get the title from the menu.
I found this is the way to get the menu items.
<?php $menu = $app->getMenu(); $menu_items = $menu->getItems('menutype', 'menu1'); var_dump ($menu_items); ?>
Couldn't be so hard but can't find the right syntax. Who could help me?
Thanks in advance,
Wims
-
user1915721 over 11 yearsThanks for your comment. This is not exactly what I ment. Iv'e solved the problem bij setting Joomla to show menu titles. In index.php I added style="xhtml": <jdoc:include type="modules" name="menu1" style="xhtml"/> In CSS the .moduletable class changed Thanks anyway. Wims