title: Make a simple sub-menu using HTML, PHP
body: <p>I have a yii2 application, and this is a part of my layouts/main.php view:</p>
  
  <pre><code>&lt;?php
  /* @var $this \yii\web\View */
  /* @var $content string */    
  ...
  &lt;body&gt;
  &lt;?php $this-&gt;beginBody() ?&gt;
  &lt;div class="wrap"&gt;
      &lt;?php
      NavBar::begin([
          'brandLabel' =&gt; Yii::t('app', Yii::$app-&gt;name),
          'brandUrl' =&gt; Yii::$app-&gt;homeUrl,
          'options' =&gt; [
              'class' =&gt; 'navbar-default navbar-fixed-top',
          ],
      ]);
  
      // everyone can see Home page
      $menuItems[] = ['label' =&gt; Yii::t('app', 'Home'), 'url' =&gt; ['/index.php/']];
  
      // we do not need to display About and Contact pages to employee+ roles
      if (!Yii::$app-&gt;user-&gt;can('employee')) {
          //$menuItems[] = ['label' =&gt; Yii::t('app', 'About'), 'url' =&gt; ['/site/about']];
          $menuItems[] = ['label' =&gt; Yii::t('app', 'Contact'), 'url' =&gt; ['/site/contact']];
      }
  
      // display Users to admin+ roles
      if (Yii::$app-&gt;user-&gt;can('admin')){
          $menuItems[] = ['label' =&gt; Yii::t('app', 'Users'), 'url' =&gt; ['/user/index']];
      }
  
      // display Logout to logged in users
      if (!Yii::$app-&gt;user-&gt;isGuest) {
          //add items, rooms etc. to menu for logged in users
          $menuItems[] = ['label' =&gt; Yii::t('app', 'Personnel'), 'url' =&gt; ['/person/index']];
          $menuItems[] = ['label' =&gt; Yii::t('app', 'Items'), 'url' =&gt; ['/item/index']];
          $menuItems[] = ['label' =&gt; Yii::t('app', 'Locations'), 'url' =&gt; ['/location/index/']];
          $menuItems[] = ['label' =&gt; Yii::t('app', 'Buildings'), 'url' =&gt; ['/building/index/']];
          $menuItems[] = ['label' =&gt; Yii::t('app', 'Rooms'), 'url' =&gt; ['/room/index/']];
          $menuItems[] = [
              'label' =&gt; Yii::t('app', 'Logout'). ' (' . Yii::$app-&gt;user-&gt;identity-&gt;username . ')',
              'url' =&gt; ['/site/logout'],
              'linkOptions' =&gt; ['data-method' =&gt; 'post']
          ];
      }
  
      // display Signup and Login pages to guests of the site
      if (Yii::$app-&gt;user-&gt;isGuest) {
          $menuItems[] = ['label' =&gt; Yii::t('app', 'Signup'), 'url' =&gt; ['/site/signup']];
          $menuItems[] = ['label' =&gt; Yii::t('app', 'Login'), 'url' =&gt; ['/site/login']];
      }
  
      echo Nav::widget([
          'options' =&gt; ['class' =&gt; 'navbar-nav navbar-right'],
          'items' =&gt; $menuItems,
      ]);
  
      NavBar::end();
      ?&gt;
  </code></pre>
  
  <p>As you can see, I have <em>location</em>, <em>room</em> and <em>building</em> in my menu. However, I'd like to only have <em>location</em> in the main menu, and <em>room</em> and <em>building</em> in <em>location's</em> sub-menu. Is there a simple way to do this?</p>