Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  * wtp : categoria padre
  * wth : categoria hija (subcategoria)
  * wtt : taxonomia
  * wtr : relacion taxonomia termino
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function buscador($params = null)
 {
     $query = Posts::find();
     $tbl_wt = Terms::tableName();
     $tbl_wtt = TermTaxonomy::tableName();
     $tbl_wtr = TermRelationships::tableName();
     $query->alias('p');
     $query->leftJoin($tbl_wtr . ' wtr', 'p.ID = wtr.object_id');
     $query->leftJoin($tbl_wtt . ' wtt', 'wtt.term_taxonomy_id = wtr.term_taxonomy_id');
     $query->leftJoin($tbl_wt . ' wtp', 'wtp.term_id = wtt.parent');
     $query->leftJoin($tbl_wt . ' wth', 'wth.term_id = wtt.term_id');
     $query->andWhere(['p.post_status' => self::ESTADO_PUBLICADO]);
     $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(['like', 'p.post_type', $this->tipo])->andFilterWhere(['like', 'wtt.taxonomy', $this->taxonomia])->andFilterWhere(['like', 'wtp.slug', $this->categoria_slug])->andFilterWhere(['like', 'wth.slug', $this->sub_categoria_slug])->andFilterWhere(['like', 'p.post_name', $this->articulo_slug]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPublicaciones()
 {
     return $this->hasMany(TermRelationships::className(), ['object_id' => 'ID']);
 }
Esempio n. 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTerminosRelacionados()
 {
     return $this->hasMany(TermRelationships::className(), ['term_taxonomy_id' => 'term_taxonomy_id']);
 }