view.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. 'title',
  19. 'sub_title',
  20. 'summary',
  21. [
  22. 'attribute' => 'thumb',
  23. 'format' => 'raw',
  24. 'value' => function($model){
  25. return "<img style='max-width:200px;max-height:200px' src='" . $model->thumb . "' >";
  26. }
  27. ],
  28. 'seo_title',
  29. 'seo_keywords',
  30. 'seo_description',
  31. [
  32. 'attribute' => 'status',
  33. 'value' => function($model){
  34. return Constants::getStatusItems($model->status);
  35. }
  36. ],
  37. 'sort',
  38. 'author_id',
  39. 'author_name',
  40. 'scan_count',
  41. 'comment_count',
  42. [
  43. 'attribute' => 'can_comment',
  44. 'value' => function($model){
  45. return Constants::getYesNoItems($model->can_comment);
  46. }
  47. ],
  48. [
  49. 'attribute' => 'visibility',
  50. 'value' => function($model){
  51. return Constants::getYesNoItems($model->visibility);
  52. }
  53. ],
  54. [
  55. 'format' => 'raw',
  56. 'attribute' => 'content',
  57. 'value' => function($model){
  58. /** @var common\models\Article $model */
  59. return $model->articleContent->content;
  60. }
  61. ],
  62. 'created_at:datetime',
  63. 'updated_at:datetime',
  64. ],
  65. ]) ?>