Yii Framework Forum: Cmenu In Module - Yii Framework Forum

Jump to content

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

Cmenu In Module Does not highlight the active link by default Rate Topic: -----

#1 User is offline   GSTAR 

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

Posted 26 February 2014 - 05:33 PM

When I use CMenu widget in a module, it doesn't highlight the active link by default:

<?php $this->widget('zii.widgets.CMenu', array(
	'items'=>array(
		array('label'=>'Home', 'url'=>array('default/index')),
	),
)); ?>


This same code works fine in main application but just not in a module.

For the highlight to work I have to do this:

<?php $this->widget('zii.widgets.CMenu', array(
	'items'=>array(
		array('label'=>'Home', 'url'=>array('default/index'), 'active'=>$this->id == 'default'),
	),
)); ?>


Or this:

<?php $this->widget('zii.widgets.CMenu', array(
	'items'=>array(
		array('label'=>'Home', 'url'=>array('admin/default/index'),
	),
)); ?>


Is this a bug or am I doing something wrong?
0

#2 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 737
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 26 February 2014 - 11:36 PM

hi try to add a slash in the front that might do the trick
...
// like soo
array('label'=>'Home', 'url'=>array('/admin/default/index'),
...

0

#3 User is offline   GSTAR 

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

Posted 27 February 2014 - 04:43 AM

Yes that does work - however I wanted to have this as a reusable widget across modules - so therefore I don't want to specify the module name in the url.

Since it generates the correct url I don't understand why it fails to highlight the active link.
0

#4 User is offline   GSTAR 

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

Posted 02 March 2014 - 03:45 PM

Anybody got any idea?
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