0

如何使用 yii 框架使用 CMenu 和 twitter Bootstrap 实现下拉菜单。没有下拉我能够完成任务但下拉我卡住了?

http://yiiistrap.blogspot.in/2013/07/yii-framework-with-twitter-bootstrap-in.html

4

2 回答 2

1

这是基本语法http://www.cniska.net/yii-bootstrap/

        <div class="btn-toolbar">
            <?php
            $this->widget('bootstrap.widgets.TbButtonGroup', array(
                'type' => 'primary',
                'buttons' => array(
                    array('label' => 'Action', 'items' => array(
                            array('label' => 'Action', 'url' => '#'),
                            array('label' => 'Another action', 'url' => '#'),
                            array('label' => 'Something else', 'url' => '#'),
                            array('label' => 'Separate link', 'url' => '#'),
                    )),
                ),
            ));
            ?>
        </div>

我有一个用户表(模型名称是 TblUser),如下所示

        ----------------
        id      username
        ----------------
        1       Hearaman
        2       Dileep
        3       Rakesh
        -----------------

前任:

我想在下拉列表中显示用户列表,当您选择链接时,它必须转到相应的用户配置文件

        <?php
        $usersAry = CHtml::listData(TblUser::model()->findAll(array('order' => 'id')), 'id', 'username');

        //$usersAry comes with id as key and username as value
        //echo "<pre>";
        //print_r($usersAry);
        //echo "</pre>";

        $items=array();
        foreach ($usersAry as $userId=>$user)
        {
            $items[]=array('label'=>$user,'url'=>'/user/view/'.$userId);
        }
        ?>

        <div class="btn-toolbar">
            <?php
            $this->widget('bootstrap.widgets.TbButtonGroup', array(
                'type' => 'primary',
                'buttons' => array(
                    array('label' => 'User List', 'items' => $items),
                ),
            ));
            ?>
        </div>
于 2013-07-08T07:39:49.453 回答
0

您还可以在引导程序中使用按钮下拉菜单

   $this->widget('bootstrap.widgets.TbButtonGroup', array(
  'type' => 'primary', // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
    'buttons' => array(
                    array('label' => 'Action', 'url' => '#'), // this makes it split :)
                    array('items' => array(
                    array('label' => 'Action', 'url' => '#'),
                    array('label' => 'Another action', 'url' => '#'),
                    array('label' => 'Something else', 'url' => '#'),
                    array('label' => 'Separate link', 'url' => '#'),
    )),
    ),

));

或在导航栏菜单中,您可以像这样添加子菜单..

   array('label'=>'First Link', 'url'=>"#", 'itemOptions'=>array('id' => 'xyz'))
于 2013-07-08T07:12:05.273 回答