yii2 How to create Sidebar menu

Hi, i’d like to create a sidebar menu on my app.

In Yii1 i have:

  • In the layout i have a Div like so

...

<?php $this->widget('UserMenu'); ?>

...

  • in the project root i have a folder "components" with

UserMenu.php

that calls


components/view/userMenu.php

How to do this with yii2?

Where to put this widget and where? (there is no "components" folder in my basic theme)

thank’s for any help

You can use same approach. Check this guide: http://www.yiiframew…reating-widgets

Thank you ifelse, i don’t know why i miss this section thas is what i need. ;D

I follow the guide but now i have this problem:

The command:


<?= UserMenu::widget();?>

generate the right HTML but in the frontend page it appear like a string with all the source html code in my sidebar.

Can anyone help me, if i miss something or what can i look to solve this?

thank’s

EDIT: after much time i find the stupid origin

in the example that i copy, i don’t look this:


return Html::encode($this->message);

i simply remove the Html:encode() and now all works fine.