M
M
Michael2019-08-11 11:12:54
Yii
Michael, 2019-08-11 11:12:54

How to style menu items in Menu::widget?

Hello everybody! Please tell me how to add one more span to the menu item in Menu::widget. Currently, when using this design

['label' => 'Обращения', 'icon' => 'commenting-o', 'url' => '/contact-form/index',],

produces the following output
<a href="/contact-form/index">
     <i class="fa fa-commenting-o"></i>  
     <span>Обращения</span>
</a>

I want the menu item to look like this
<a href="/contact-form/index">
    <i class="fa fa-commenting-o"></i>
    <span>Обращения</span>
    <span class="pull-right-container">
        <span class="label label-primary pull-right">
        <?= $count_contact; ?>
        </span>
    </span>
</a>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Bay, 2019-08-11
@kawabanga

'encode' => false,
and already make any span in the title

D
Dmitry, 2019-08-11
@slo_nik

Good afternoon.
In addition to doing what @kawabanga wrote (although it would be more correct to use encodeLabel), you can try to further customize the widget using the following methods:
$labelTemplate
$lastItemCssClass
$linkTemplate
$submenuTemplate
and a bunch of other ways.
More details here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question