Get the Alias of the Active Menu Item
Safely fetches the alias (slug) of the active menu item for CSS hooks, analytics tags or conditional layout logic.
<?php
declare(strict_types=1);
use Joomla\CMS\Factory;
$menuItemAlias = (string) (Factory::getApplication()->getMenu()->getActive()?->alias ?? '');