Yii Framework Forum: CMenu widget and active highlighting - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CMenu widget and active highlighting Rate Topic: -----

#1 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,035
  • Joined: 30-October 09
  • Location:UK

Posted 22 February 2010 - 06:49 AM

Here is my Users menu link:

array('label'=>'Users, 'url'=>array('/user/index), 'visible'=>!Yii::app()->user->isGuest),


I want this link to remain highlighted when user navigates to all sub-links of 'user', for example: user/admin, user/view, user/update, user/create
0

#2 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,035
  • Joined: 30-October 09
  • Location:UK

Posted 22 February 2010 - 10:07 AM

Anyone able to advise?
0

#3 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 22 February 2010 - 10:56 AM

array(
    'label'=>'Users', 
    'url'=>array('/user/index'),
    'active'=>Yii::app()->controller->id=='User',
    'visible'=>!Yii::app()->user->isGuest
),

1

#4 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,035
  • Joined: 30-October 09
  • Location:UK

Posted 22 February 2010 - 11:00 AM

Good stuff. Looks like this functionality has changed from v1.0 (it used to do it automatically).
0

#5 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 22 February 2010 - 11:05 AM

View PostGSTAR, on 22 February 2010 - 11:00 AM, said:

Good stuff. Looks like this functionality has changed from v1.0 (it used to do it automatically).


A link will be "active" if it links to the current page.
In your case, if you are viewing user/update page, then a menu item "index" (which links to user/index or user) won't be active, because actions are different.
1

#6 User is offline   Mikhail Eremin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 09-February 10

Posted 25 February 2010 - 02:41 AM

View Postandy_s, on 22 February 2010 - 10:56 AM, said:

array(
    'label'=>'Users', 
    'url'=>array('/user/index'),
    'active'=>Yii::app()->controller->id=='User',
    'visible'=>!Yii::app()->user->isGuest
),




Yeah!! Thanx for that solution. It works. Especially when you use extensions based on cmenu. they don't want to do it automatically, for some reason, but it works like that.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users