简体   繁体   中英

Create equivalent of CMenu Zii widget with Yii booster

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 ie defining CSS classes where needed?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM