Condition if its a module

Hi,

into the layout on navigation i need conditions to check if it’s a module, controller name or action to put an active class into the navigation element.

With controllers and actions i have no problems:


<li class="treeview<?= Yii::$app->controller=='site' && Yii::$app->controller->action=='index' ? ' active' : ''; ?>">..</li>

How i can check the module name? Yii::$app->module==‘modulename’ nothings return.

Try


Yii::$app->controller->module->id