menu.php 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. use app\models\base\NewsTopic;
  3. use yii\widgets\ListView;
  4. echo Yii::$app->cache->getOrSet("archive_rubrics-amp0",function () {
  5. return \yii\widgets\ListView::widget([
  6. "dataProvider" => new \yii\data\ActiveDataProvider([
  7. "query"=>NewsTopic::find()->andWhere(["show"=>"Y","active"=>1,"topic_id"=>null])->orderBy(["order"=>SORT_ASC]), //"topic_id"=>$topic->id next lavel maybe
  8. "pagination" =>[
  9. "pageSize"=>0
  10. ],
  11. ]),
  12. 'options' => [
  13. 'tag' => "ul",
  14. 'class' => 'list-reset m0 p0 ampstart-label',
  15. 'id' => 'list-wrapper',
  16. ],
  17. "itemOptions"=>[
  18. "tag"=>"li",
  19. "class"=>"ampstart-nav-item"
  20. ],
  21. "itemView" => function($model) {
  22. if( $model->url == '----'){
  23. $ret = \yii\helpers\Html::tag('div','',['class' => ['hr']]);
  24. //$ret .= \yii\helpers\Html::tag('span',$model->title,['class' => ['header']]);
  25. return $ret;
  26. }
  27. return \yii\helpers\Html::a($model->title,["news/{$model->url}"]);
  28. },
  29. "layout" => "{items}"
  30. ]);
  31. },1);//NewsTopic::$keysCache['archive_rubrics-##']