Search code examples
yiitwitter-bootstrapyii-extensions

Yii-extension Bootstrap: navbar 'pull-right' class


I am trying to align one of the navbars texts to the right but nothing I try is working.

My code is:

<?php $this->widget('bootstrap.widgets.BootNavbar', array(
'fixed'=>true,
'brand'=>'',
'brandUrl'=>'#',
'collapse'=>true, // requires bootstrap-responsive.css
'items'=>array(
    array(
        'class'=>'bootstrap.widgets.BootMenu',
        'items'=>array(
            array('label'=>'Weblog', 'url'=>'#'),
            array('label'=>'Local RiverMap', 'url'=>'#', 'items'=>array(
                array('label'=>'Radar', 'url'=>'#'),
                array('label'=>'Cosmo7', 'url'=>'#'),
                array('label'=>'Neige', 'url'=>'#'),
                array('label'=>'Fonte Neige', 'url'=>'#'))),
            array('label'=>'Global RiverMap', 'url'=>'#', 'items'=>array(
                array('label'=>'Precipitations 24h', 'url'=>'#'),
                array('label'=>'Precipitations 72h', 'url'=>'#'),
                array('label'=>'Precipitations 240h', 'url'=>'#'))),
            array('label'=>'Espace Expert', 'url'=>'#'),
            array('label'=>'Tableau Du Bord', 'url'=>'#', 'items'=>array(
                array('label'=>'Tableau du Bord', 'url'=>'#'),
                array('label'=>'Niveau de Lacs', 'url'=>'#'),
                array('label'=>'Prevision LEPS', 'url'=>'#'),
                array('label'=>'Performance', 'url'=>'#'),
                array('label'=>'Exported Files', 'url'=>'#'))),
            array('label'=>'Admins', 'url'=>'#', 'items'=>array(
                array('label'=>'Edit Menu', 'url'=>'#'),
                array('label'=>'Edit Google Objects', 'url'=>'#'),
                array('label'=>'Insert Internal Message', 'url'=>'#'),
                array('label'=>'Message log', 'url'=>'#'),
                array('label'=>'Insert Clients Message', 'url'=>'#'))),
            array('label'=>'logout', 'url'=>'#', 'htmlOptions'=>array('class'=>'pull-right')),

      ),
            ),
     ))); ?>

As you can see I want last item 'logout' to be at the right side of the navbar but I really don't know how to do it and I can't find any info in the web. The only thing I have seen is using the 'htmlOptions'=>array('class'=>'pull-right') but it doenst seem to work.

When I execute the code with fire bug I can see as that element has 'class'=''.

I would also like to know how I can introduce an image in any navbar item!

Thank you!


Solution

  • The only real difference I see between your BootNavBar widget and mine is that I have 'fixed' set to false and I have 2 BootMenus, the second BootMenu calls the class=>'pull-right'.

    $this->widget('bootstrap.widgets.BootNavbar', array(
    'fixed'=>false,
    'brand'=>CHtml::encode(Yii::app()->name),
    'brandUrl'=>'/',
    'collapse'=>true,
    'items'=>array(
        array(
            'class'=>'bootstrap.widgets.BootMenu',
            'items'=>array(
                array('label'=>Yii::t('layouts','Home'), 'url'=>array('/site/index')),
                array('label'=>Yii::t('layouts','About'), 'url'=>array('/site/page', 'view'=>'about')),
                array('label'=>Yii::t('layouts','Contact'), 'url'=>array('/site/contact')),
            ),
        ),
        array(
            'class'=>'bootstrap.widgets.BootMenu',
            'htmlOptions'=>array('class'=>'pull-right'),
            'items'=>array(
                array('label'=>Yii::t('layouts','Login'), 'url'=>array('/login'), 'visible'=>Yii::app()->user->isGuest),
            ),
        ),
        $logoutHtml,
    ),
    

    ));