_layout.php 911 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: NODELOG
  5. * Date: 2016/12/15
  6. * Time: 下午3:14
  7. */
  8. /**
  9. * @var \yii\web\View $this
  10. * @var common\modules\book\models\Book $book
  11. */
  12. use common\helpers\Tree;
  13. $chapters = $book->chapters;
  14. $items = [];
  15. foreach ($chapters as $chapter) {
  16. $item = [];
  17. $item['label'] = $chapter->chapter_name;
  18. $item['url'] = empty($chapter->chapter_body) ? '#' : ['chapter', 'id' => $chapter->id];
  19. $item['active'] = request('id') == $chapter->id && Yii::$app->controller->action->id == 'chapter';
  20. $item['id'] = $chapter->id;
  21. $item['pid'] = $chapter->pid;
  22. $items[] = $item;
  23. }
  24. $menuItems = Tree::build($items, 'id', 'pid', 'items');
  25. ?>
  26. <div class="row">
  27. <div class="col-md-3">
  28. <?= \common\widgets\SideNavWidget::widget([
  29. 'items' => $menuItems
  30. ]) ?>
  31. </div>
  32. <div class="col-md-9">
  33. <?= $content ?>
  34. </div>
  35. </div>