1

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?

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.