public function get_bannersAction()
 {
     $type = $this->request->getQuery('type');
     $banners = Banners::find(array('type = :type:', 'bind' => array('type' => $type)))->toArray();
     $arr = array('banners' => $banners);
     if ($this->request->getQuery('type') == 'image') {
         $arr['directory'] = $this->url->get($this->config->banners->imagePath);
     } elseif ($this->request->getQuery('type') == 'flash') {
         $arr['directory'] = $this->url->get($this->config->banners->flashPath);
     }
     echo json_encode($arr);
 }
Пример #2
0
 public static function getCarousel()
 {
     $slider = [];
     $items = Banners::find()->all();
     foreach ($items as $item) {
         $slide = '';
         if (!empty($item->url)) {
             $slide .= Html::beginTag('a', ['href' => $item->url]);
         }
         $slide .= Html::img($item->getUploadUrl('photo'));
         if (!empty($item->url)) {
             $slide .= Html::endTag('a');
         }
         $slider[] = $slide;
     }
     return $slider;
 }
Пример #3
0
 /**
  * Lists all Banners models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Banners::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }