/** * Displays static page. * @param $slug * @return string * @throws NotFoundHttpException */ public function run($slug) { $model = new Paginas(); if (($pagina = $model->obtenerPaginaPorSlug($slug)) === null) { throw new NotFoundHttpException('La página solicitada no existe.'); } return $this->controller->render('pagina-estatica', ['model' => $pagina]); }
/** * Creates a new Paginas model. * If creation is successful, the browser will be redirected to the 'view' page. * @return string|\yii\web\Response */ public function run($categoria = null) { $model = new Paginas(); $modelCategoria = new PaginasCategorias(); if (!empty($categoria)) { $model->categoria = $modelCategoria->obtenerIdCategoria($categoria); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->controller->redirect(['detalle', 'id' => $model->idpagina]); } else { return $this->controller->render('create', ['model' => $model]); } }
/** * Crear una pagina en la categoria ayuda */ public function actionCrearPaginaAyuda($categoria = null) { $categoria = !empty($categoria) ? intval($categoria) : 12; $model = new Paginas(); $model->titulo = 'App probando desde consola'; $model->contenido = 'App probando desde consola'; $model->categoria = $categoria; $model->autor = 4; $model->estado = 'publicado'; $model->tipo = 'pagina'; $model->contenido = 'App probando desde consola'; if ($model->save()) { echo "Pagina ayuda creada " . $model->idpagina; } }
/** * Finds the PaginasCategorias model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return PaginasCategorias the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Paginas::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Paginas::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id_pag' => $this->id_pag, 'meta_id' => $this->meta_id, 'imagen_id' => $this->imagen_id, 'autor_id' => $this->autor_id, 'creado' => $this->creado, 'actualizado' => $this->actualizado]); $query->andFilterWhere(['like', 'titulo', $this->titulo])->andFilterWhere(['like', 'contenido', $this->contenido])->andFilterWhere(['like', 'estado', $this->estado])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'meta_code_css', $this->meta_code_css])->andFilterWhere(['like', 'meta_code_js', $this->meta_code_js]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Paginas::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['idpagina' => $this->idpagina, 'categoria' => $this->categoria, 'padre' => $this->padre, 'plantilla' => $this->plantilla, 'autor' => $this->autor, 'fechacreado' => $this->fechacreado, 'fechaactualizado' => $this->fechaactualizado]); $query->andFilterWhere(['like', 'titulo', $this->titulo])->andFilterWhere(['like', 'contenido', $this->contenido])->andFilterWhere(['like', 'leermas', $this->leermas])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'estado', $this->estado])->andFilterWhere(['like', 'tipo', $this->tipo])->andFilterWhere(['like', 'meta_titulo', $this->meta_titulo])->andFilterWhere(['like', 'meta_palabras', $this->meta_palabras])->andFilterWhere(['like', 'meta_descripcion', $this->meta_descripcion]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getPagina0() { return $this->hasOne(Paginas::className(), ['idpagina' => 'pagina']); }
/** * @return \yii\db\ActiveQuery */ public function getPaginas() { return $this->hasMany(Paginas::className(), ['plantilla' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getContenido1() { return $this->hasOne(Paginas::className(), ['idpagina' => 'contenido']); }
/** * @return \yii\db\ActiveQuery */ public function getIdPags() { return $this->hasMany(Paginas::className(), ['id_pag' => 'id_pag'])->viaTable('paginas_categoria', ['id_categoria' => 'id_categoria']); }
/** * @return \yii\db\ActiveQuery */ public function getPaginas() { return $this->hasMany(Paginas::className(), ['categoria' => 'idcategoria']); }