Here is some simple idea that could be easily added on a comming release.
There idea was to have the same as in this example from bootstrap home:
twitter.github.com/bootstrap/examples/fluid.html
A button, or other sub-menus that don't collapse on the NavBar. So I created a new class that extends from the TbNavBar, add a new property $fixedItem and render them just after the brand link and before the collapse check.
Here is the full class that extends from TbNavBar
<?php
Yii::import('ext.bootstrap.widgets.TbNavbar');
class TbwNavbar extends TbNavbar {
public $fixedItems = array();
/**
* Runs the widget.
*/
public function run() {
$containerCssClass = $this->fluid ? 'container-fluid' : 'container';
echo CHtml::openTag('div', $this->htmlOptions);
echo '<div class="navbar-inner"><div class="' . $containerCssClass . '">';
if ($this->collapse) {
echo '<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">';
echo '<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>';
echo '</a>';
}
if ($this->brand !== false)
echo CHtml::openTag('a', $this->brandOptions) . $this->brand . '</a>';
foreach ($this->fixedItems as $item) {
if (is_string($item))
echo $item;
else {
if (isset($item['class'])) {
$className = $item['class'];
unset($item['class']);
$this->controller->widget($className, $item);
}
}
}
if ($this->collapse) {
$this->controller->beginWidget('bootstrap.widgets.TbCollapse', array(
'toggle' => false,
// navbars should be collapsed by default
'htmlOptions' => array(
'class' => 'nav-collapse'
),
));
}
foreach ($this->items as $item) {
if (is_string($item))
echo $item;
else {
if (isset($item['class'])) {
$className = $item['class'];
unset($item['class']);
$this->controller->widget($className, $item);
}
}
}
if ($this->collapse)
$this->controller->endWidget();
echo '</div></div></div>';
}
}
And this is config for the TbwNavBar:
$this->widget(
'bootswatch.widgets.TbwNavbar',
array(
'type' => 'inverse',
'brand' => CHtml::tag('div', array(
'class' => 'navbar-logo'
), ' ', true) . Yii::app()->name,
'brandUrl' => $this->createUrl('/site/index'),
'collapse' => true,
'items' => array(
array(
'class' => 'bootstrap.widgets.TbMenu',
'items' => array(
array(
'icon' => 'home white',
'label' => 'Home',
'url' => array(
'/site/index'
)
),
array(
'icon' => 'info-sign white',
'label' => 'About',
'url' => array(
'/page/view',
'alias' => 'about'
)
),
array(
'icon' => 'bullhorn white',
'label' => 'Contact',
'url' => array(
'/site/contact'
)
),
array(
'icon' => 'cog white',
'label' => 'Admin',
'visible' => (Yii::app()->user->getName() == 'admin'),
'items' => array(
array(
'label' => 'Dashboard',
'url' => array(
'/admin'
)
),
'<hr>',
array(
'label' => 'People',
'url' => array(
'/admin/person'
)
),
array(
'label' => 'Emails',
'url' => array(
'/admin/email'
)
),
array(
'label' => 'Subscriptions',
'url' => array(
'/admin/subscription'
)
)
)
)
)
)
),
'fixedItems' => array(
array(
'class' => 'bootstrap.widgets.TbButtonGroup',
'htmlOptions' => array(
'class' => 'pull-right'
),
'buttons' => array(
array(
'class' => 'bootstrap.widgets.TbMenu',
'icon' => 'user',
'label' => Yii::app()->user->name,
'items' => array(
array(
'icon' => 'list-alt',
'label' => 'Profile',
'url' => array(
'/user/profile'
)
),
array(
'icon' => 'off',
'label' => 'Logout',
'url' => array(
'/site/logout'
)
)
)
)
)
)
)
));
Sure the code is still kind of raw, e.g. the htmlOptions of the fixed button group needs to be set with class 'pull-right' and the property name $fixedItems maybe isn't so good and I'm also duplicating code in the render of $fixedItems, but it works just fine for me.
Looking forward to hear your comments.

Help















