Frage

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?

War es hilfreich?

Lösung

I found the answer: CWidget->controller returns the current controller. So: $this->controller->isActive(); can be used in the widget class or its view.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top