I am trying to create a menu in Yii2
using Nav::widget
and what I have to do is to render the menu like this:
<li id="dashboard">
<a href="<?php echo Yii::$app->homeUrl; ?>?r=users/dashboard" class="active-title">
<span class="nav-icon"><i class="icon-dashboard icon-2x"></i></span>
<span class="sidebar-menu-item-text">Dashboard</span></a>
</li>
And what I am currently doing is this:
[
'label' => 'Dashboard',
'url' => ['users/dashboard'],
'options' => ['id' => 'dashboard'],
],
And this renders in browser like this:
<li id="dashboard" class="active"><a href="/yiitwo/laps/frontend/web/index.php?r=users%2Fdashboard">Dashboard</a></li>
So, what I want to do is to put a span
inside <a>
tag. How can i do it?
答案 0 :(得分:1)
[
'label' => '<span class="nav-icon"><i class="icon-dashboard icon-2x"></i></span><span class="sidebar-menu-item-text">Dashboard</span>',
'encode' => false,
'url' => ['users/dashboard'],
'options' => ['id' => 'dashboard'],
],