view.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2016-04-14 12:09
  7. */
  8. use common\libs\Constants;
  9. use yii\widgets\DetailView;
  10. /**
  11. * @var $model common\models\Article
  12. */
  13. ?>
  14. <?= DetailView::widget([
  15. 'model' => $model,
  16. 'attributes' => [
  17. 'id',
  18. [
  19. 'attribute' => 'category',
  20. 'value' => function($model){
  21. return $model->category === null ? "-" : $model->category->name;
  22. }
  23. ],
  24. 'title',
  25. 'sub_title',
  26. 'summary',
  27. [
  28. 'attribute' => 'thumb',
  29. 'format' => 'raw',
  30. 'value' => function($model){
  31. return "<img style='max-width:200px;max-height:200px' src='" . $model->thumb . "' >";
  32. }
  33. ],
  34. 'seo_title',
  35. 'seo_keywords',
  36. 'seo_description',
  37. [
  38. 'attribute' => 'status',
  39. 'value' => function($model){
  40. return Constants::getStatusItems($model->status);
  41. }
  42. ],
  43. 'sort',
  44. 'template',
  45. 'author_id',
  46. 'author_name',
  47. 'scan_count',
  48. 'comment_count',
  49. [
  50. 'attribute' => 'can_comment',
  51. 'value' => function($model){
  52. return Constants::getYesNoItems($model->can_comment);
  53. }
  54. ],
  55. [
  56. 'attribute' => 'visibility',
  57. 'value' => function($model){
  58. return Constants::getArticleVisibility($model->visibility);
  59. }
  60. ],
  61. 'password',
  62. [
  63. 'attribute' => 'flag_headline',
  64. 'value' => function($model){
  65. return Constants::getYesNoItems($model->flag_headline);
  66. }
  67. ],
  68. [
  69. 'attribute' => 'flag_recommend',
  70. 'value' => function($model){
  71. return Constants::getYesNoItems($model->flag_recommend);
  72. }
  73. ],
  74. [
  75. 'attribute' => 'flag_slide_show',
  76. 'value' => function($model){
  77. return Constants::getYesNoItems($model->flag_slide_show);
  78. }
  79. ],
  80. [
  81. 'attribute' => 'flag_special_recommend',
  82. 'value' => function($model){
  83. return Constants::getYesNoItems($model->flag_special_recommend);
  84. }
  85. ],
  86. [
  87. 'attribute' => 'flag_roll',
  88. 'value' => function($model){
  89. return Constants::getYesNoItems($model->flag_roll);
  90. }
  91. ],
  92. [
  93. 'attribute' => 'flag_bold',
  94. 'value' => function($model){
  95. return Constants::getYesNoItems($model->flag_bold);
  96. }
  97. ],
  98. [
  99. 'attribute' => 'flag_picture',
  100. 'value' => function($model){
  101. return Constants::getYesNoItems($model->flag_picture);
  102. }
  103. ],
  104. [
  105. 'format' => 'raw',
  106. 'attribute' => 'content',
  107. 'value' => function($model){
  108. /** @var \common\models\Article $model */
  109. return $model->articleContent->content;
  110. }
  111. ],
  112. 'created_at:datetime',
  113. 'updated_at:datetime',
  114. ],
  115. ]) ?>