newsList.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. $this->title="Новости";
  3. //тест (заменить на новостьи дня и по календарику)
  4. $newsDataProvider = new \yii\data\ActiveDataProvider(
  5. [
  6. "query"=>\app\models\News::getMainView()->orderBy(["dt_pub"=>SORT_DESC])->limit(50),
  7. "pagination" =>[
  8. "pageSize"=>50
  9. ],
  10. ]
  11. );
  12. /*
  13. $newsDataProvider = new \yii\data\ActiveDataProvider(
  14. [
  15. "query"=>\app\models\base\News::find()->orderBy(["dt_pub"=>SORT_DESC])->limit(50),
  16. "pagination" =>[
  17. "pageSize"=>50
  18. ],
  19. ]
  20. );
  21. */
  22. /**** ****/
  23. ?>
  24. <div class="table-responsive-sm custom-range-badge">
  25. <table class="table table-hover table-Light">
  26. <thead class="bg-gray table-sm">
  27. <tr>
  28. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">время</th>
  29. <th scope="col" class="col-md-1 col-sm-2 col-xs-5">фото</th>
  30. <th scope="col">заголовок</th>
  31. <th scope="col">статусы</th>
  32. <th scope="col">управление</th>
  33. </tr>
  34. </thead>
  35. <tbody>
  36. <?
  37. foreach( $newsDataProvider->getModels() as $item ){
  38. // print_r($item->getTopics());
  39. $strTopics = '';
  40. foreach( $item->getTopics()->primaryModel->topics as $topic ){
  41. $strTopics = $strTopics." [".$topic->title."]";
  42. }
  43. $strbage = '';
  44. if( $item->verifed == 'Y' ) $strbage .= '<span class="badge badge-success font-weight-normal">проверено</span><br>';
  45. if( $item->top == 'Y' ) $strbage .= '<span class="badge badge-primary font-weight-normal">важная</span><br>';
  46. if( $item->NH == 'Y' ) $strbage .= '<span class="badge badge-info font-weight-normal">НЧ</span><br>';
  47. ?>
  48. <tr>
  49. <th scope="row" class="text-nowrap"><?=date("h:i d-m-Y",strtotime($item->dt_pub))?></th>
  50. <td><img src="/images/news/news/<?=$item->id?>.jpg"></td>
  51. <td><?=$item->title?><br><small><?=$strTopics?><br><?=$item->editors?></small></td>
  52. <td><?=$strbage?></td>
  53. <td><div class="btn-group btn-group-toggle" data-toggle="a" role="group"><a href="new?id=<?=$item->id?>" title="Править" role="button" class="btn btn-secondary btn-sm"><i class="far fa-edit"></i></a><a href="" title="спрятать" role="button" class="btn btn-secondary btn-sm"><i class="far fa-eye-slash"></i></a><a href="" role="button" class="btn btn-secondary btn-sm">в топ</a><a href="/news/<?=$item->id?>" title="открыть на сайте" role="button" class="btn btn-secondary btn-sm" target="_blank"><i class="far fa-window-restore"></i></a></div></td>
  54. </tr>
  55. <?
  56. // <pre>
  57. // print_r($item);
  58. // </pre>
  59. ?>
  60. <?
  61. }
  62. ?>
  63. </tbody>
  64. </table>
  65. </div>
  66. <?php
  67. //print_r($newsDataProvider->getModels());