Reputation: 2652
How do I implement menus using Yii-bootstrap or yii booster? For example the menu on the default layout of Yii is as follows-
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Home', 'url'=>array('/site/index')),
array('label'=>'Search', 'url'=>array('/product/search')),
array('label'=>'Contact', 'url'=>array('/site/contact')),
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)
),
)); ?>
This has a good functionality. What is the Yii-Bootstrap or Yii-Booster way of implementing this and taking control of the design i.e defining CSS classes where needed?
Upvotes: 1
Views: 1823
Reputation:
In Yii-booster it is TbMenu
, in Yii-bootstrap it is probably BootMenu
, here is some example:
$this->widget('bootstrap.widgets.TbMenu', array(
'type' => 'tabs', // <-- also try 'pills' here for different styling or 'list' for vertical menu
'items' => array(
// Your items here
)
);
EDIT: There is also TbNavbar
component for creating main navigation bar, it takes TbMenu
as one of it's parameters:
$this->widget('bootstrap.widgets.TbNavbar', array(
'brand' => 'Title', // <-- This dysplays some title on the left
'items' => array(
array(
'class' => 'bootstrap.widgets.TbMenu',
'items' => array(
// Typical Yii menu items config
)
)
)
));
Upvotes: 2