Unfortunately, yii\widgets\Menu does not support dynamic menu (having menu items stored in a database).
In a portal I previously developed, and which was not MVC/framework based (procedurally programmed), it was fairly easy to generate a multilevel menu using nested HTML lists, dynamically from a database table, and with only a single query – given a simple helper, recursive function to work through a multidimensional array.
Basically the same way as in the linked example, with the following differences:
Instead of two separate functions, you might want to create a custom widget class which is responsible for both building the database query and rendering the result.
Instead of mysql_* functions, yii\db\* should be used for database access.
yii\helpers\Html can simplify the rendering process a bit (less string concatenations).
"Menu widget that loads Kartik sidenav widget with database items."
and in turn, Kartik sidnav extends the Yii Menu widget.
One limitation is that Kartik sidenav CSS supports only up to 3 levels of submenus, so CSS would need to be customized to support 4-levels, per my needs.
and since the widget outputs HTML lists (with some styling), I think it shouldn’t be too difficult to integrate with something like smartmenus.org