0

CMenu と twitter Bootstrap を使用して、yii フレームワークでドロップダウン メニューを実現する方法。ドロップダウンなしでタスクを達成できますが、ドロップダウンで立ち往生しますか?

http://yiistrap.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' => '#'),
    )),
    ),

));

または Navbar メニューで、このようなサブメニューを追加できます..

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