how to disable side-navbar label encode
Closed this issue · 1 comments
devmrh commented
hi i used material icon on my navbar ... in sidenav i see their code instead icons how can i disable label encode? thankyou
i used
sideNavClientOptions' => [
'encodeLabels' => false
]
but didnt work
NavBar::begin([
'brandOptions' => [
'class' => 'hide-on-med-and-down'
],
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'fixed' => false,
'wrapperOptions' => [
'class' => 'nav-wrapper'
],
]);
$menuItems = [
['label' => '<i class="material-icons">search</i>'],
['label' => '<span style="position: relative;top: 8px" id="message"><span class="material-icons">email</span></span><span class="new badge orange darken-3 message">' . $m_count . '</span>'],
['label' => '<i class="material-icons">view_module</i>'],
['label' => '<i class="material-icons">refresh</i>'],
['label' => '<i class="material-icons">more_vert</i>', 'items' => [ // will be rendered as dropdown
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Home', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']]
]],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
$menuItems[] = ['label' => 'Login', 'url' => ['/user/login']];
} else {
$menuItems[] = '<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-flat']
)
. Html::endForm()
. '</li>';
}
echo Nav::widget([
'encodeLabels' => false,
'options' => ['class' => 'right'],
'items' => $menuItems,
'sideNavToggleButtonOptions' => [
'class' => 'show-on-small',
'label' => '',
'icon' => [
'name' => 'menu'
],
'type' => Button::TYPE_FLAT,
],
'sideNavClientOptions' => [
'encodeLabels' => false
]
]);
NavBar::end();
?>
MacGyer commented
Simply set the encode
property for the nav item:
['label' => '<i class="material-icons">search</i>', 'encode' => false],