CMenu multiple submenu


(Sean2253) #1

Can a 2 layer horizontal menu be created using CMenu? (Each link on the upper layer should render a different submenu.)

For me, the example the documentation produces the same submenu for each upper link, and the login link disappears.

Thanks Sean2253


$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),


),

));



(Thyseus) #2

Take a look at the ‘NavBar’-Style of the superfish plugin:

http://users.tpg.com.au/j_birch/plugins/superfish/#sample4

(click on ‘Examples’ after this url has been loaded)

It can easily be used within yii using the CDropDownMenu Extension.

This is a wrapper for the superfish plugin and can be set to ‘navbar’ style.


(Sean2253) #3

Thanks Thyseus.

I will try this.

Sean2253.


(Sean2253) #4

Thanks Thyseus.

However I do not want a menu that changes with/without hover.

I want each submenu to persist when its parent link is clicked.

I may have to do a hardcoded querystring based system?

Sean2253.


(Poppitypop) #5

http://www.yiiframework.com/doc/api/CMenu#activateParents-detail

http://www.yiiframework.com/doc/api/CMenu#items-detail

See the ‘active’ option

You’re just going to have to mess around with the different options and the CSS


(C Ramkumar) #6

$this->widget('zii.widgets.CMenu', array(

       'activeCssClass'=>'active',

	'id'=>'navigation',

        

	'items'=>array(

            

        array('label'=>'Cal4info', 'url'=>array('/site/index')),

        array('label'=>'Hot Deals', 'url'=>array('/company/aboutUs'),

           

            'submenuOptions'=>array('class'=>'nav-sub'),'items'=>array(

            array('label'=>'SubItem1', 'url'=>array('site/anot','id'=>'12')),

            array('label'=>'SubItem2', 'url'=>array('site/anot','id'=>'13')),

        )

            

            

            ),

        array('label'=>'Event', 'url'=>array('/company/careers'),

                 

            'submenuOptions'=>array('class'=>'nav-sub'),'items'=>array(

            array('label'=>'SubItem1', 'url'=>array('site/anot','id'=>'12')),

            array('label'=>'SubItem2', 'url'=>array('site/anot','id'=>'13')),

      

            )),

        array('label'=>'Travels', 'url'=>array('/company/contactUs')),

        array('label'=>'Hospital', 'url'=>array('/company/storeLocator')),

        array('label'=>'Real Estate', 'url'=>array('/company/storeLocator')),

        array('label'=>'Advertise', 'url'=>array('/company/storeLocator')),

        array('label'=>'Contact', 'url'=>array('/site/contact')),

      ),

	'htmlOptions'=>array('class'=>'nav-main'),

));


#navigation {

	margin:0;

	padding: 0;

	clear:both;

	width:1000px;

	height:51px;

	background: #d6eaf8 url(images/dropdown-bg.gif) repeat-x left top;

}




ul.nav-main,

ul.nav-main li {

	list-style: none;

	margin: 0;

	padding: 0;

}




ul.nav-main {

	position: relative;

	z-index: 597;

}


ul.nav-main li:hover > ul {

	visibility: visible;

}




ul.nav-main li.hover,

/*ul.menu1 li a.first{border-left:1px solid #37526b;}*/

ul.nav-main li.active a{

	position: relative;

	z-index: 599;

	cursor: pointer;

	background: url(images/dropdown-bg-hover.gif) repeat-x left top;

}

ul.nav-main li:hover {

	position: relative;

	z-index: 599;

	cursor: pointer;

	background: url(images/dropdown-bg-hover.gif) repeat-x left top;

}





ul.nav-main li {

	float:left;

	display:block;

	height: 51px;

	color: #999;

	font: 14px Arial, Helvetica, sans-serif;

	background: url(images/separator.gif) no-repeat right center;

}


ul.nav-main li a {

	display:block;

	padding: 16px 16px 0 16px;

	height: 35px;

	color: #999;

	font: 14px Arial, Helvetica, sans-serif;

	text-decoration:none;

}


ul.nav-main li a:hover {

	color:#D6D6D6;

}





ul.nav-main *.list {

	padding-right: 22px;

	background: url(images/navigation-arrow.gif) no-repeat right top;

}





ul.nav-sub {

	visibility: hidden;

	position: absolute;

	padding:10px;

	top: 48px;

	left: 0;

	z-index: 598;

	background: #353535 url(images/dropdown-list-bg.gif) repeat-x left top;

	border-right: 1px solid #000;

	border-bottom: 1px solid #000;

	border-left: 1px solid #000;

}




ul.nav-sub li {

	list-style:none;

	display:block;

	padding: 0;

	height: 27px;

	float: none;

	width:145px;

	border-bottom: 1px solid #5a5a5a;

	background: none;

}


ul.nav-sub li a {

	list-style:none;

	display:block;

	padding: 6px 5px 6px 5px;

	height: 15px;

	float: none;

	width:145px;

	background: none;

	font: 12px Arial, Helvetica, sans-serif;	

}







(mayur parmar) #7

Hi,

i want make static menubar for this i wrote this code :

<?php $this->widget(‘zii.widgets.CMenu’,array(

‘items’=>array(

array(‘label’=>‘Home’, ‘url’=>array(’/site/index’)),

array(‘label’=>‘Company’, ‘url’=>’#’

‘items’=>array(

array(‘label’=>‘About Us’,

‘items’=>array(

array(‘label’=>‘Our Story’, ‘url’=>’#’),

array(‘label’=>‘Our Differance’, ‘url’=>’#’),

array(‘label’=>‘Our Working Methedology’, ‘url’=>’#’),

)),

array(‘label’=>‘Client’,

‘items’=>array(

array(‘label’=>‘Testimonial’, ‘url’=>’#’),

array(‘label’=>‘Client Vedio Testimonial’, ‘url’=>’#’),

)),

)),

array(‘label’=>‘Services’, ‘url’=>’#’

‘items’=>array(

array(‘label’=>‘Moblie Application’,

‘items’=>array(

array(‘label’=>‘IPhone App Development’, ‘url’=>’#’),

array(‘label’=>‘IPad App Development’, ‘url’=>’#’),

array(‘label’=>‘Android App Development’, ‘url’=>’#’),

array(‘label’=>‘Windows Moblie Development’, ‘url’=>’#’),

array(‘label’=>‘Cross-Platform Development’, ‘url’=>’#’),

)),

array(‘label’=>‘Web Development’,

‘items’=>array(

array(‘label’=>‘Mobile App Web Development’, ‘url’=>’#’),

array(‘label’=>‘Web Application Development’, ‘url’=>’#’),

array(‘label’=>‘Web Design And Development’, ‘url’=>’#’),

array(‘label’=>‘E-Commerce Web Development’, ‘url’=>’#’),

array(‘label’=>‘CMS Website Development’, ‘url’=>’#’),

)),

)),

array(‘label’=>‘Solutions’, ‘url’=>’#’

‘items’=>array(

array(‘label’=>‘Technology’,

‘items’=>array(

array(‘label’=>‘PHP Development’, ‘url’=>’#’),

array(‘label’=>‘Open Source Development’, ‘url’=>’#’),

array(‘label’=>‘Microsoft Technology Development’, ‘url’=>’#’),

)),

array(‘label’=>‘Staffing’,

‘items’=>array(

array(‘label’=>‘Hire IPhone App Developer’, ‘url’=>’#’),

array(‘label’=>‘Hire IPad App Developer’, ‘url’=>’#’),

array(‘label’=>‘Hire Android App Developer’, ‘url’=>’#’),

array(‘label’=>‘Hire PHP Developer’, ‘url’=>’#’),

array(‘label’=>‘Hire HTML5 Developer’, ‘url’=>’#’),

)),

)),

array(‘label’=>‘Portfolio’, ‘url’=>array(’/site/visitors’)),

array(‘label’=>‘Case Studies’, ‘url’=>array(’/site/visitors’)),

array(‘label’=>‘Get A Quote’, ‘url’=>array(’/site/visitors’)),

array(‘label’=>‘Login’, ‘url’=>array(’/site/login’), ‘visible’=>Yii::app()->user->isGuest),

array(‘label’=>‘Logout (’.Yii::app()->user->name.’)’, ‘url’=>array(’/site/logout’), ‘visible’=>!Yii::app()->user->isGuest)

),

));

but it can’t work well and give a parse error like :

Parse error: syntax error, unexpected ‘‘items’’ (T_CONSTANT_ENCAPSED_STRING), expecting ‘)’ in C:\xampp\htdocs\mayur\demoapp\protected\views\layouts\main.php on line 41.

please give me solution for this error.

give me replay as soon as you can…

thank you.


(The Coder) #8

Please add ‘,’ after array(‘label’=>‘Company’, ‘url’=>’#’