How to make item in the widget Menu?

I need to get the following menu

<ul class="sidebar_nav--list">
 <li class="sidebar_nav--item"><a href>Fruits / Vegetables <span class="count">(3)</span></a></li>
 <li class="sidebar_nav--item"><a href>Meat / Poultry</a></li>
 <li class="sidebar_nav--item">
 <a class="active" href>Cold drink</a>
 <ul class="sidebar_nav--sub">
 <li class="sidebar_nav--item"><a href>Sausages <span class="count">(1)</span></a></li>
 <li class="sidebar_nav--item"><a href>Sausage varenokopchenye <span class="count">(4)</span></a></li>
 <li class="sidebar_nav--item"><a href>Sausage jerked</a></li>
</ul>
</li>
</ul>


given that this is a <span class="count">(1)</span> calculated value that's the way I form

foreach ($categorys as $category){
$menuItems[$category->id]=[
 'active' => false,
 'label' => !$category->has_childs?"$category->name <span class="count">".count($category->products)."</span>":$category->name,
'options'=>['class'=>'sidebar_nav--item'],
 'url' => Url::toRoute(["catalog/category", 'id' => $category->id]),
];
 }


get get but here it is. Tell me how can I properly execute ?
June 10th 19 at 14:24
2 answers
June 10th 19 at 14:26
Solution
Good evening.
Use encodeLabels
Default true, set to false.
June 10th 19 at 14:28
In continuation to the previous response. An example of use is in the menu

echo Menu::widget([
 'items' => [
 ['label' => '<i class="fa fa-user"></i> List of judges', 'url' => ['judge/index']],
 ['label' => '<i class="fa fa-user-plus"></i> Destination <span class="badge red">5</span>', 'url' => ['appointment/index']],
 ['label' => '<i class="fa fa-book"></i> Category', 'url' => ['judge-comitet/index']],

],
 'options' => [
 'class' => 'nav nav-pills nav bottom-justified' ,
'style'=>'margin-bottom:20px'
],
'activateItems'=>true,
'activateParents'=>true,
 'encodeLabels' =>false,
]);


Or if you are using Admin LTE template

[
 'label' => MarketingModule::t('marketing','Marketing'),
 'icon' => 'bullhorn',
 'active' => $moduleId === 'marketing',
 'items' => [
[
 'label' => MarketingModule::t('discount', 'Discounts'),
 'url' => ['/marketing/discount/index'],
 'visible' => Yii::$app->user->can('/marketing/discount/*'),
 'icon' => 'angle-double-right',
 'active' => $controller == 'discount',
],
[
 'label' => MarketingModule::t('lead', 'Leads'),
 'url' => ['/marketing/lead/index'],
 'visible' => Yii::$app->user->can('/marketing/lead/*'),
 'icon' => 'angle-double-right',
 'active' => $controller == 'lead',
],
]
],
Yes blunted represent used
'encodeLabels' =>'false',
and waited for the result here it is that lack of sleep does )) - vergie.Jerde commented on June 10th 19 at 14:31
duck all right. Can be meant to true. - jacquelyn_Nikolaus84 commented on June 10th 19 at 14:34
had without quotes. - vergie.Jerde commented on June 10th 19 at 14:37
and)) Yeah) It didn't even look. Thought the word
encodeLabels
not correctly wrote... it Happens! - jacquelyn_Nikolaus84 commented on June 10th 19 at 14:40

Find more questions by tags Yii