AleCat83
(Alessandro Cattaneo83)
1
Hello,
I’m building a web application using yii2 framework and yii2-admin extension.
I’m trying to create a new menu with the yii2-admin menu manager but I can’t find clear explenations on how to do this task.
Can someone explain me each step needed to create a menu with yii2-admin?
Thank you
Alessandro
AleCat83
(Alessandro Cattaneo83)
3
Hi, thank you for reply.
I’ve already read the official documentation but unfortunately can’t understand how this system work.
In particular:
Which files I need to create/edit? And where to save them?
How I bind a user role to a specific menu item?
Thank you
Alessandro
Hi,
after install module and it works fine.
you should add routes to enable you to create menu items.
- add routes (index.php?r=admin%2Froute%2Findex)
then go to menu (index.php?r=admin%2Fmenu%2Fcreate)
and start to create items, in Route field, you will see routes that you added.
final step: add this code in layout/main.php it will show menu items.
use mdm\admin\components\MenuHelper;
use yii\bootstrap\Nav;
echo Nav::widget([
'items' => MenuHelper::getAssignedMenu(Yii::$app->user->id)
]);
many thanks
AleCat83
(Alessandro Cattaneo83)
5
Hi, thank you for your reply.
I’ve added some routes from the avaliable list and then I’ve created 2 menu items as shown in the attachments.
After that I’ve added the following code in the layout/main.php
use mdm\admin\components\MenuHelper;
use yii\bootstrap\Nav;
echo Nav::widget([
'items' => MenuHelper::getAssignedMenu(Yii::$app->user->id)
]);
maybe I need to add some code to the config/web.php file?
Thank you
Ale
AleCat83
(Alessandro Cattaneo83)
6
Got it! I’ve forgot to add re routes to the user role!
Now it seems to work fine!
Thank you very much
Alessandro
AleCat83
(Alessandro Cattaneo83)
8
I hav 2 other questions… 
-
is it possible to add route and relative menu item for guests? I need to add the login menu item to not logged in guest
-
the logout route give me this error:
Method Not Allowed. This url can only handle the following request methods: POST.
is there a way to fix this?
Hello,
I am trying yii2 admin.
how to show assign menu for user role, for example admin role.
I have configure layout/main.php and add two menu like AleCat83 do.
I have add also two routes that I used to create menu to add routes in role admin, but display no one.
Please help me…