Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     if (!isset($params['parent_id'])) {
         throw new \Exception('Property parent_id must be setted');
     }
     $query = CarouselRecord::find()->where(['parent_id' => $params['parent_id']]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]], 'pagination' => ['pageSize' => 10]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'active' => $this->active, 'sort' => $this->sort, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'image', $this->image]);
     return $dataProvider;
 }
Example #2
0
 protected function _initItems()
 {
     $this->_items = CarouselRecord::find()->where(['active' => CarouselRecord::$STATUS_IS_ACTIVE])->andWhere(['parent_id' => self::PARENT_ID])->orderBy(['sort' => SORT_ASC])->all();
 }
Example #3
0
                <!--menu-->
                <?php 
echo MainMenuWidget::widget(['items' => Yii::$app->mainMenu->getMainMenu()]);
?>
                <!-- menu end -->

            </div>  
            <div class="clear"></div>

            <?php 
echo Alert::widget();
?>
            
            <!-- carousel -->
            <?php 
echo CarouselWidget::widget(['items' => CarouselRecord::find()->where(['active' => CarouselRecord::$STATUS_IS_ACTIVE, 'parent_id' => 22])->orderBy(['sort' => SORT_ASC])->all()]);
?>
            <!-- content area -->
            
            
            <?php 
echo $content;
?>
  
            
            <!-- end of content area -->
            
            <div class="clear" style="height:100px;"></div>
            
            <div id="footer">
                <div id="footer_menu_body">