Yii Framework Forum: CMenu multiple submenu - Yii Framework Forum

Jump to content

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

CMenu multiple submenu 2 layer horizontal menu Rate Topic: -----

#1 User is offline   sean2253 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 01-March 10

Posted 01 March 2010 - 12:49 PM

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),
),
));
--------------------------------------------
0

#2 User is offline   thyseus 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 300
  • Joined: 18-April 09
  • Location:Leipzig, Germany

Posted 01 March 2010 - 02:51 PM

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

http://users.tpg.com...erfish/#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.
0

#3 User is offline   sean2253 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 01-March 10

Posted 01 March 2010 - 03:37 PM

Thanks Thyseus.

I will try this.


Sean2253.
0

#4 User is offline   sean2253 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 01-March 10

Posted 02 March 2010 - 05:05 AM

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.
0

#5 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 02 March 2010 - 02:35 PM

http://www.yiiframew...eParents-detail

http://www.yiiframew...nu#items-detail
See the 'active' option

You're just going to have to mess around with the different options and the CSS
http://php-thoughts.cubedwater.com - my bloggings about Yii
0

#6 User is offline   ram87 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 12-February 13

Posted 28 May 2013 - 06:33 AM

$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;	
}



0

#7 User is offline   mayur2111 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 28-June 13

Posted 02 July 2013 - 06:06 AM

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.
0

#8 User is offline   Code-Guru 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 25-July 13

Posted 25 July 2013 - 05:52 AM

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


View Postmayur2111, on 02 July 2013 - 06:06 AM, said:

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.

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