YiiBooster - 项目的htmlOptions不起作用?

时间:2013-02-17 15:32:47

标签: yii yii-extensions yii-booster

我正在使用http://yii-booster.clevertech.biz/components.html#navbar,我想要生成导航栏。我有一个问题,因为我必须在其中一个项目上使用pull-right css类。

为什么htmlOptions不起作用?如何在“用户”项目上使用pull-right

$this->widget('bootstrap.widgets.TbNavbar', array(
    'brand' => CHtml::encode($this->pageTitle),
    'brandUrl' => '#',
    'collapse' => true,
    'type' => 'inverse',
    'items' => array(
        array(
            'class' => 'bootstrap.widgets.TbMenu',
            'items' => array(
                array('label'=>'Home', 'url'=>'#', 'active'=>true),
                array('label'=>'Link', 'url'=>'#'),
                array('label'=>'Link', 'url'=>'#'),
                array('label'=>'User (895)', 'htmlOptions'=>array('class'=>'pull-right'),
                    'items'=>array(
                        array('label'=>'Support', 'url'=>'#'),
                        array('label'=>'Mailing', 'url'=>'#'),
                        array('label'=>'Sklep', 'url'=>'#'),
                        array('label'=>'Profile', 'url'=>'#'),
                        array('label'=>'Logout', 'url'=>'#'),
                    )
                ),
            )
        )
    )
));

2 个答案:

答案 0 :(得分:3)

请尝试:

$this->widget('bootstrap.widgets.TbNavbar', array(
    'brand' => CHtml::encode($this->pageTitle),
    'brandUrl' => '#',
    'collapse' => true,
    'type' => 'inverse',
    'items' => array(
        array(
            'class' => 'bootstrap.widgets.TbMenu',
            'items' => array(
                array('label'=>'Home', 'url'=>'#', 'active'=>true),
                array('label'=>'Link', 'url'=>'#'),
                array('label'=>'Link', 'url'=>'#'),
                array('label'=>'User (895)', 'itemOptions'=>array('class'=>'pull-right'),
                    'items'=>array(
                        array('label'=>'Support', 'url'=>'#'),
                        array('label'=>'Mailing', 'url'=>'#'),
                        array('label'=>'Sklep', 'url'=>'#'),
                        array('label'=>'Profile', 'url'=>'#'),
                        array('label'=>'Logout', 'url'=>'#'),
                    )
                ),
            )
        )
    )
));

答案 1 :(得分:1)

哦,我明白了。应该这样写:

$this->widget('bootstrap.widgets.TbNavbar', array(
    'brand' => CHtml::encode($this->pageTitle),
    'brandUrl' => '#',
    'collapse' => true,
    'type' => 'inverse',
    'items' => array(
        array(
            'class' => 'bootstrap.widgets.TbMenu',
            'items' => array(
                array('label'=>'Home', 'url'=>'#', 'active'=>true),
                array('label'=>'Link', 'url'=>'#'),
                array('label'=>'Link', 'url'=>'#'),
            )
        ),
        array(
            'class' => 'bootstrap.widgets.TbMenu',
            'htmlOptions'=>array('class'=>'pull-right'),
            'items' => array(
                array('label'=>'Name Surname (895)',
                    'items'=>array(
                        array('label'=>'Support', 'url'=>'#'),
                        array('label'=>'Mailing', 'url'=>'#'),
                        array('label'=>'Sklep', 'url'=>'#'),
                        array('label'=>'Profile', 'url'=>'#'),
                        array('label'=>'Logout', 'url'=>'#'),
                    )
                ),
            )
        ),
    )
));
相关问题