public function run() { if (isset($_GET['tag'])) { $query = Post::getAdapterForPosts($this->limit, $_GET['tag']); } else { $query = Post::getAdapterForPosts($this->limit); } $dpPosts = new ActiveDataProvider(array('query' => $query, 'pagination' => array('pageSize' => $this->limit))); //here we don't return the view, here we just echo it! return $this->render('@frenzelgmbh/sblog/widgets/views/_posts', array('dpPosts' => $dpPosts)); }
public function run() { $hits = NULL; $model = new PostSearch(); if ($model->load(Yii::$app->request->post())) { if ($model->searchstring !== '') { $hits = Post::searchByString($model->searchstring)->all(); } } echo $this->render('@frenzelgmbh/sblog/widgets/views/_search', array('model' => $model, 'hits' => $hits)); }
public function search($params) { $query = Post::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->addCondition($query, 'id'); $this->addCondition($query, 'title', true); $this->addCondition($query, 'content', true); $this->addCondition($query, 'tags', true); $this->addCondition($query, 'status', true); $this->addCondition($query, 'author_id'); $this->addCondition($query, 'created_at'); $this->addCondition($query, 'updated_at'); return $dataProvider; }
/** * Finds the Post model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Post the loaded model * @throws HttpException if the model cannot be found */ protected function findModel($id) { if (($model = Post::findOne($id)) !== null) { return $model; } else { throw new HttpException(404, 'The requested page does not exist.'); } }