Yii Framework Forum: Smenu | How to make the Parent Menu item active - Yii Framework Forum

Jump to content

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

Smenu | How to make the Parent Menu item active Rate Topic: -----

#1 User is offline   PeRoChAk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 579
  • Joined: 26-November 10
  • Location:Lahore, Pakistan

Posted 30 November 2010 - 01:46 AM

Hi dears,

I am using the SMenu for the menu of my application.
I want to make the top menu active if the sub menu item is being active.

I.e.

if in the menu list there are
Main ->
sub 1
sub 2
and if the user is on the page sub 2
then the top menu Main should be set active.

Please help me in it.

Thanks
Cheers
Perochak
Web Design - Logo Design - Application Development

My Blog | Forums Comparison
0

#2 User is offline   PeRoChAk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 579
  • Joined: 26-November 10
  • Location:Lahore, Pakistan

Posted 01 December 2010 - 03:53 AM

I have done it using CMenu.

I modified the CMenu such that it fits in the required domain.

Thanks
Cheers
Perochak
Web Design - Logo Design - Application Development

My Blog | Forums Comparison
0

#3 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 394
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 13 December 2010 - 07:58 AM

View PostPeRoChAk, on 01 December 2010 - 03:53 AM, said:

I have done it using CMenu.

I modified the CMenu such that it fits in the required domain.

Thanks

Could you please explain how you did that?
Posted Image
0

#4 User is offline   PeRoChAk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 579
  • Joined: 26-November 10
  • Location:Lahore, Pakistan

Posted 15 December 2010 - 04:59 AM

We can have it using the Active property of the Cmenu

If we have a items in our sub menu which belongs to the different controllers then we can use a custom code as fellow to have our top menu item active

$sub_menu_controllers=array('site','site2','site3');
$sub_menu_active='false';
if(in_array(Yii::app()->controller->id,$sub_menu_controllers)){
$sub_menu_active='true';
}


Now in your CMenu widget, we can have

			$this->widget('zii.widgets.CMenu', array(
                        'items'=>array(
                         array('label'=>'Title','URL'=>'','active'=>$sub_menu_active),
                          );


This is just a trick to get what I want.

It could be Improved.

Hopefully, will help someone.

Thanks
Cheers
Perochak
Web Design - Logo Design - Application Development

My Blog | Forums Comparison
0

#5 User is offline   Alex_Ros 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 05-January 14
  • Location:Ukraine

Posted 10 January 2014 - 05:10 AM

Hi All,

As described here http://www.yiiframew...eParents-detail
normally, to make parent menu item active (by 'active' i mean that when you are on example.com/page/6 , Page in main menu should be also with class='active')
it is enough to simply pass parameter 'activateParents'=>'true' in a CMenu widget

But it is still not working.

Does anyone know where the problem is?

Thanks in advance,
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