D
D
Dmitry Baskakov2019-12-04 09:12:44
Joomla
Dmitry Baskakov, 2019-12-04 09:12:44

How to get the id of the current menu item in Joomla 3?

It is necessary to highlight the current menu item where the user is located. Those. if the user has entered the gallery, then the gallery should be highlighted in the site header. From the front, I know how to implement it, but I'm not sure about the back.
There is a plan: when going to a certain page, get the ID of the current menu item and do a small check in the code: is this or that menu item active

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton R., 2019-12-04
@anton_reut

$app = JFactory::getApplication();
$menu = $app->getMenu()->getActive()->id;
echo $menu;

https://stackoverflow.com/questions/19067435/jooml... Googling
kung fu, huh.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question