Yii Framework Forum: A Way To Make Cmenu Top-Level Item Unselectable? - Yii Framework Forum

Jump to content

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

A Way To Make Cmenu Top-Level Item Unselectable? Rate Topic: -----

#1 User is offline   C Hodges 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 08-April 13

Posted 08 April 2013 - 11:11 PM

The topic kind of says what I'm trying to get to. So for example if have this:

$this->widget('zii.widgets.CMenu', array(
    'items'=>array(
        array('label'=>'Home', 'url'=>array('site/index')),
        array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
            array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
            array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
        )),
        array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),
    ),
));


Is there a way to make the top-level 'Products" menu item un-selectable. In instance the Products top-level is just a label for the items that sit below and shouldn't do anything. Cant' seem to figure out how to make this work this way.

Much appreciate your help with this.

--
Chris
0

#2 User is offline   hiral darji 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 31-May 12
  • Location:Ahmedabad

Posted 09 April 2013 - 12:07 AM

View PostC Hodges, on 08 April 2013 - 11:11 PM, said:

The topic kind of says what I'm trying to get to. So for example if have this:

$this->widget('zii.widgets.CMenu', array(
    'items'=>array(
        array('label'=>'Home', 'url'=>array('site/index')),
        array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
            array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
            array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
        )),
        array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),
    ),
));


Is there a way to make the top-level 'Products" menu item un-selectable. In instance the Products top-level is just a label for the items that sit below and shouldn't do anything. Cant' seem to figure out how to make this work this way.

Much appreciate your help with this.

--
Chris



As per I understand your problem you want to remove product as a link,

so for that cchange you product menu like this,

array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
            array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
            array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
        ), 'itemOptions'=>array('id'=>'product')),


and in your this view file on top write following script

<script>
$(document).ready(function () {
$('#product a').click(function(){ 
	return false;
});
});
</script>


0

#3 User is offline   C Hodges 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 08-April 13

Posted 09 April 2013 - 10:17 AM

That's what I was looking for. Thanks so much!


View Posthiral darji, on 09 April 2013 - 12:07 AM, said:

As per I understand your problem you want to remove product as a link,

so for that cchange you product menu like this,

array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
            array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
            array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
        ), 'itemOptions'=>array('id'=>'product')),


and in your this view file on top write following script

<script>
$(document).ready(function () {
$('#product a').click(function(){ 
	return false;
});
});
</script>



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