I found the answer: CWidget->controller returns the current controller. So: $this->controller->isActive(); can be used in the widget class or its view.
Using Controller method from a widget's view in Yii
-
29-03-2022 - |
Vra
I have a simple task that I want to achieve - I have a navbar widget and I want to add "active" class to links that leading to the currently displayed page.
Cetver's answer @ Yii how to highlight the current menu item gives me a pretty method that I need to put in a Controller class. It works like a charm in controllers and views.
I do need to use it in my widget's view... how do I access it from there?
Oplossing
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow