/** * Finds the Posts model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param $categoria * @param $sub_categoria * @return \yii\data\ActiveDataProvider * @throws NotFoundHttpException if the model cannot be found */ protected function obtenerPublicaciones($categoria, $sub_categoria) { $model = new PublicacionesBuscador(); $model->tipo = PublicacionesBuscador::TIPO_PRENSA; $model->categoria_slug = $categoria; $model->sub_categoria_slug = $sub_categoria; $dp = $model->buscador(); if ($dp->getCount() > 0 || $dp !== null) { return $dp; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Finds the Posts model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param $categoria * @param $sub_categoria * @param $articulo * @return \yii\data\ActiveDataProvider * @throws NotFoundHttpException if the model cannot be found */ protected function obtenerPublicacion($categoria, $sub_categoria, $articulo) { $model = new PublicacionesBuscador(); $model->tipo = PublicacionesBuscador::TIPO_PRENSA; $model->categoria_slug = $categoria; $model->sub_categoria_slug = $sub_categoria; $model->articulo_slug = $articulo; $dp = $model->buscador(); if ($dp->getCount() > 0) { return $dp; } else { throw new NotFoundHttpException('El articulo solicitado no existe.'); } }
public function actionDemo() { // $post = Yii::$app->blog->newPost('New post', 'Hola mundo'); // $post = Yii::$app->blog->cache(function (Wordpress $blog) { // return $blog->getPosts([ // 'post_type' => 'prensa', // 'post_status' => 'publish', // 'terms' => 'campañas', //// 'orderby' =>, //// 'order' =>, // 'number' => 10 // ]); //// ], ['guid', 'post_title', 'post_content']); // }); // $post = new Posts(); // $post = Posts::find()->all(); // echo '<pre>';print_r([__LINE__, __METHOD__,'hola mundo',TermRelationships::find()->all()]);die(); $post = new PublicacionesBuscador(); $post->tipo = Posts::TIPO_SOPORTE; $post->categoria_slug = 'mi-cuenta'; return $this->render('demo', ['post' => $post->buscador([])]); }