This extension is a very simple to use multi-level top menu based on jqueryslidemenu : http://www.dynamicdrive.com/style/csslibrary/item/jquery_multi_level_css_menu_2/
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/components
Usage ¶
See the following code example:
<?php
$this->widget('application.components.JQuerySlideTopMenu.JQuerySlideTopMenu', array(
'items'=>array(
array('label'=>'Home', 'url'=>array('site/index')),
array('label'=>'WIKI', 'url'=>'#', 'subs'=>array(
array('label'=>'New article', 'url'=>'#'),
), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Blog', 'url'=>'#', 'subs'=>array(
array('label'=>'New post', 'url'=>'#'),
), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Admin tools', 'url'=>'#', 'subs' => array(
array('label'=>'Users', 'url'=>'#', 'subs' => array(
array('label'=>'Add new user', 'url'=>array('auth.users/create')),
array('label'=>'List', 'url'=>array('auth.users/list')),
)),
array('label'=>'Customers', 'url'=>'#', 'subs' => array(
array('label'=>'Add new', 'url'=>'#'),
array('label'=>'List', 'url'=>'#'),
)),
array('label'=>'Projects', 'url'=>'#', 'subs' => array(
array('label'=>'Add new', 'url'=>'#'),
array('label'=>'List', 'url'=>'#'),
)),
array('label'=>'Accounting setup', 'url'=>'#', 'subs' => array(
array('label'=>'Employees', 'url'=>'#'),
array('label'=>'Bank accounts', 'url'=>'#'),
array('label'=>'Settings', 'url'=>'#'),
)),
array('label'=>'Roles & Permissions', 'url'=>'#'),
array('label'=>'Settings', 'url'=>'#'),
), 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'My profile', 'url'=>'#', 'visible'=>!Yii::app()->user->isGuest),
array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Logout', 'url'=>array('site/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
));
?>
Change Log ¶
February 24, 2009 ¶
- Initial release.
This didn't work on mine
Hi Guys,
I put main.css inside CSS folder (replacing current main.css) and i put JQuerySlideTopMenu folder inside protected/components (so it become protected/components/JQuerySlideTopMenu/JQuerySlideTopMenu.php
Then i copy php code in this JquerySlideTopMenu documentation (http://www.yiiframework.com/extension/jqueryslidetopmenu/#doc) replacing my current menu in protected/views/layouts/main.php
But when i run my Yii Application in browser, why did the menu become only Home and Login?it seems like the other menu which has submenu didn't work and did'nt even showed up.
Somebody help me pleaseeeee....
remove display: inline from main.css
nyto,
I also have the same problem, and I have found main.css conflicts with jqueryslidemenu.css in #mainmenu like following:
#mainmenu ul li
{
display: inline;
background: #90B3DC;
}
#mainmenu ul li a
{
In my case, just removing above line is enough.
You can explore css files using firebug or other extension with ease.
The menu is not working after fix
Guys, this menu is using unchanged dynamicdrive code so this is definitely not the extension bug. I think you are trying it with default Yii testdrive application? So there seems to be a conflict with default Yii css styles... I will upload main.css file that works for me.
Undefined index: subs
Yeah.. I have the same problem like henqi..
Waiting for update..
The menu is not working after fix
I need to add this code
isset($item['subs']) &&
in 2 files in both JQuerySlideTopMenu.php and view.php to avoid yii complain the error/warning
item['subs']
is undefine index.
After fixed, the top menu appeared, but it behave incorrectly as shown at dynamicdrive dot com, the space between each menuitem seems like too width, when mouse hover over to next bottom menuitem, the menu behave like mouse already move out, and simply disappeared.
Can you please help and comment ?? I still new to Yii, and first to MVC framwork.
URL with view option
the following command (link with 'view' option) not working properly:
array('label'=>'Sobre', 'url'=>array('/site/page', 'view'=>'about')),
So I had to make some changes in code:
if(isset($item['url'])) { $item2['url']= CHtml::normalizeUrl($item['url']); } else $item2['url']=CHtml::tag('span',isset($item['linkOptions']) ? $item['linkOptions'] : array(), $item['label']);
this is correct?
Login to see submenus
In reply to mitoasoy
These menus aren't visible to guest users, so You must login to see them
or just comment out the lines
'visible'=>!Yii::app()->user->isGuest
URL with view option
In reply to Luiz:
to get url with options working, would be enough to replace
$item2['url']=$controller->createUrl($item['url'][0]);
by
$item2['url']=CHtml::normalizeUrl($item['url']);
Submenu not show up on mouseover
follow comments mitoasoy and use the instructions, I had the same problem, I already logged in when i mouseover on "admin tools", sub menu (including image down.gif) still does not work submenu doese not showing, anyone give me solution, Thanks
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.